PDA

View Full Version : Solved: counting



oleg_v
05-04-2010, 11:59 PM
Hi

I need some help with a macro that will count the amount of cells in column "b" that the cells containment is greater than 5


thanks

GTO
05-05-2010, 12:17 AM
Try either:


Sub exa()
MsgBox Evaluate("=COUNTIF(Sheet1!B:B,"">5"")")
MsgBox WorksheetFunction.CountIf(Sheet1.Range("B:B"), ">5")
End Sub

Hope that helps,

Mark

oleg_v
05-05-2010, 12:33 AM
hi
thanks it works fine
i wanted to ask if i want to replace "5" with a variable
what should i do

thanks

Bob Phillips
05-05-2010, 12:41 AM
MsgBox Application.CountIf(Sheet1.Range("B:B"), ">" & myVar)