Countif in VBA

L

Lee Hunter

Will someone please show me an example of using countif
as a worksheet function in VBA.

I have used the "Find" function to determine the starting
row for the countif. It is stored in a var "c"

What is the correct syntax to count the number of rows
with a "1" in column B, starting with the row "c".

Thanks for your help.
 
F

Frank Kabel

Hi
try
msgbox application.worksheetfunction.countif(Range("B2 & c &
":B10000"),"1")
 
T

Tom Ogilvy

there was a typo:

msgbox application.worksheetfunction.countif(Range("B" & _
c & ":B10000"),"1")
 
G

Guest

Thanks Frank.

I received a syntax error. I believe the " are
unbalanced.

Did you mean to use Range("B"&c&":B1000").....?

This too results in a syntax error.

Can you see the probllem?

Thanks once again for your help.
 
T

Tom Ogilvy

You have guessed the typo, but created another problem by not putting a
space around the ampersand.

Range("B"&c&":B1000")

should be

Range("B" & c & ":B1000")

But then I showed you that already.
 
Top