การเขียน Code VBA หาตำแหน่งที่ Hilight
Posted: Fri Jun 10, 2016 1:52 pm
รบกวนสอบถาม Function VBA ที่คืนค่าออกมาเป็นตำแหน่งแรกที่พบสี Hilight ตรงกับสีที่กำหนด
เช่น A1:E1 มี ้hilight เหลืองที่ C1 คำตอบคือ 3 ครับ
Function MatchByColor(CellColor As Range, SumRange As Range)
Application.Volatile
Dim ICol As Range
Dim TCell As Range
ICol = CellColor.Interior.ColorIndex
For Each TCell In SumRange
If ICol = TCell.Interior.ColorIndex Then
MatchByColor = ????
End If
Next TCell
End Function
เช่น A1:E1 มี ้hilight เหลืองที่ C1 คำตอบคือ 3 ครับ
Function MatchByColor(CellColor As Range, SumRange As Range)
Application.Volatile
Dim ICol As Range
Dim TCell As Range
ICol = CellColor.Interior.ColorIndex
For Each TCell In SumRange
If ICol = TCell.Interior.ColorIndex Then
MatchByColor = ????
End If
Next TCell
End Function