What's the vba code equivalent for Countif

N

NDBC

I tried using the foloowing code

Onlap = CountIf(Worksheets("A Grade").Range("I5:I104"), L)

and it says that countif is an undefined sub or function. What is the
correct VB code in 2003 to count the number of times a number occurs in a
range.

Thanks
 
M

Mike H

Hi,

Simply tell the VB compiler it's a worksheetfunction

Onlap = WorksheetFunction.CountIf(Worksheets("A Grade").Range("I5:I104"), L)

Mike
 
N

NDBC

Not sure if it's exactly the same as your suggetions but it worked. I googled
whilst I was waiting for a response.

Onlap = Application.CountIf(Worksheets("A Grade").Range("I5:I104"), L)
 

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