Hello,
When I use the code below I get there are 1 cells with the red background color. The original cell range has A1:A4 red so why is the code not returning 4? Thanks.
When I use the code below I get there are 1 cells with the red background color. The original cell range has A1:A4 red so why is the code not returning 4? Thanks.
Code:
Sub CountCells()
' Count Cells with content or with background coloring
Dim c As Range, Cnt As Integer
Cnt = 0
For Each c In Range(Cells(ActiveCell.Row, 1), Cells(ActiveCell.Row, 256))
If c.Interior.ColorIndex = 3 Then Cnt = Cnt + 1
Next c
MsgBox "There are " & Cnt & " cells that have a red background color"
End Sub