Need to count formated Cells in Excel Macro

  • Thread starter Thread starter blackmanofsteel40
  • Start date Start date
B

blackmanofsteel40

I used a Macro to format cells based on given criteria. But now I need
a Macro to count those formatted cells and print them in a seperate
cell. I want to to use the count feature but I can't figure out how to
just count the formatted cells. This is the Macro I used to format the
cells based on the criteria:

Sub P2()


Dim LastRow As Long
Dim iRow As Long


With ActiveSheet
LastRow = .Cells(.Rows.Count, "C").End(xlUp).Row


For iRow = 3 To LastRow
If .Range("C" & iRow).Value <> .Range("H" & iRow).Value Then
.Range("H" & iRow).Interior.Color = RGB(200, 160, 35)
End If
Next iRow
End With
End Sub



Anybody got any ideas????????????
 
I came up with this and it works fine. Thanks.


Sub P3()

Dim c As Range
Dim i As Long


For Each c In ActiveSheet.UsedRange
If c.Interior.ColorIndex = 45 Then
i = i + 1
End If
Next


Range("H945").Value = 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

Back
Top