Count no of rows with interior color

S

sheeba

Hello!


Is it possible to count the nuber of rows in a range with interior
color (any)

for eg. on range "B1:F20" if any cell in B1:F1 got interior color count
it and check next row B2:F2 ... like wise and count the number of rows
in the range having atleast one cell with interior color.

thanks
 
G

Gary Keramidas

here's one way. it will count the number filled with blue (37) in column a

Option Explicit
Dim cell As Range
Dim lastrow As Long
Dim wks1 As Worksheet
Dim i As Integer
Sub count_colors()
lastrow = Worksheets("sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Set wks1 = Worksheets("Sheet1")

Dim counter As Integer
For i = lastrow To 1 Step -1
Debug.Print lastrow
If Cells(i, 1).Interior.ColorIndex = 37 Then
counter = counter + 1
End If
Next i
MsgBox counter
Debug.Print i
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top