countif usage in macro

P

parthaemail

if i give the function =countif(sheet1!E2:E12,"=Europe") in blank
shell of excel ,it gives no of rows having the word europe in the
column E . but if i give the same commend in macro it shows syntax
error .


Sub parthamacro()
'
' parthamacro Macro
' Macro recorded 2/8/2006 by 128304
'

'
Dim nResult As Long
nResult = sheet1.countif(sheet1!E2:E12,"=Europe")

End Sub


can you please help me , how to use countif function in macros
 
D

Dave Peterson

Dim myRng as range
dim nResult as long
set myrng = worksheets("sheet1").range("e2:E12")
nresult = application.countif(myrng,"europe")
 

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