VBA: Help on DCOUNT function without specifying field

  • Thread starter Thread starter Frank Krogh
  • Start date Start date
F

Frank Krogh

When I apply the DCOUNT function in the sheet without specifying field
[=DCOUNT(myCountRange;; myCriteriaRange)] counting blanks using myCriteria =
"=" , it works just fine.

But when I try to apply exactly the same function in VBA, I receive compile
error "Argument not optional":

With frmMyForm
.lMyLabel =
Application.WorksheetFunction.DCount(Range("myCountRange"), ,
Range("myCriteriaRange"))
End With

Is the DCOUNT function really implemented in two different ways?
Is there a way to ommit this problem?

Thanks for any suggestions.


Frank Krogh
 
Try it without using Worksheetfunction

? Application.DCount(Range("myCountRange"), ,Range("myCriteriaRange"))
23


worked for me.
 

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

Back
Top