tbilderbac
New Member
- Joined
- Apr 11, 2022
- Messages
- 28
- Office Version
- 365
- Platform
- Windows
- MacOS
I got this code:
-----------
Public Function CountByColor2(CellRange As Range, TargetCell As Range)
Dim TargetColor As Long, Count As Long, C As Range
TargetColor = TargetCell.Interior.ColorIndex
For Each C In CellRange
If C.Interior.ColorIndex = TargetColor Then Count = Count + 1
Next C
CountByColor2 = Count
End Function
------------
I created the formula:
=CountByColor2(RC[-23]:RC[-6],R[-16]C[-25])
and wanting it to count up the RED blocks: [should be 5]
-----------
Public Function CountByColor2(CellRange As Range, TargetCell As Range)
Dim TargetColor As Long, Count As Long, C As Range
TargetColor = TargetCell.Interior.ColorIndex
For Each C In CellRange
If C.Interior.ColorIndex = TargetColor Then Count = Count + 1
Next C
CountByColor2 = Count
End Function
------------
I created the formula:
=CountByColor2(RC[-23]:RC[-6],R[-16]C[-25])
and wanting it to count up the RED blocks: [should be 5]