ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code For Count on Conditional formatting (https://www.excelbanter.com/excel-programming/358113-code-count-conditional-formatting.html)

Aaron

Code For Count on Conditional formatting
 
Hello all,

I am looking to have code once a macro runs to be able the do a count on the
conditional formatting the was triggered on a tab. So condition1 states turn
red if the cell value is greater than 30. After a macro runs a msgbox states
there are 33 counts of condition1 on sheet1 tab.

Thanks,
Aaron

Trevor Shuttleworth

Code For Count on Conditional formatting
 
Aaron

Do you really need a macro ?

Why not just a COUNTIF ?

=COUNTIF(B:IV,"30") anywhere in column A

or

=COUNTIF(A2:A65536,"30")+COUNTIF(B:IV,"30") in cell A1

But, if you must:

Sub CountGT30_1()
MsgBox WorksheetFunction.CountIf(Range("A:IV"), "30")
End Sub

Sub CountGT30_2()
MsgBox WorksheetFunction.CountIf(Cells, "30")
End Sub

Sub CountGT30_3()
MsgBox WorksheetFunction.CountIf(Columns("A:IV"), "30")
End Sub

Sub CountGT30_4()
MsgBox WorksheetFunction.CountIf(Rows("1:65536"), "30")
End Sub

Regards

Trevor


"Aaron" wrote in message
...
Hello all,

I am looking to have code once a macro runs to be able the do a count on
the
conditional formatting the was triggered on a tab. So condition1 states
turn
red if the cell value is greater than 30. After a macro runs a msgbox
states
there are 33 counts of condition1 on sheet1 tab.

Thanks,
Aaron





All times are GMT +1. The time now is 06:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com