countif in VBA

  • Thread starter Thread starter nyn04
  • Start date Start date
N

nyn04

I try to use the following to count positive occurances


Application.CountIf(range("tradesdiff"), ">0")
Application.CountIf([tradesdiff], ">0")

my TradesDiff is defined
Dim TradesDiff()
m= 17

ReDim TradesDiff(m)

then I run a loop to fill in the values

what do I have to do to be able to use the countif property

when I run the count proerty I get a correct result??
Application.Count(TradesDiff)


thank yo
 
WorksheetFunction.CountIf(Range("tradesdiff"), ">0")

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
MsgBox WorksheetFunction(Range("TradesDiff"), "<0")

I run this and I get nothing

any ideas

my variable is defined as

Dim tradesDiff ()]

m = 300

Redim (m)
I am new to vba, when I put the values in excel cells I can then ru
the countif on the excel sheet but I need to avoid that, my values ru
from 17 to 40

thank yo
 
This sort of syntax

MsgBox WorksheetFunction(Range("TradesDiff"), "<0")

is working on a worksheet range called Tradesdiff, not a vraibale. SO just
call the populated worksheet cells Tradesdiff and it should work.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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

Similar Threads

worksheetfunction 1
colors and countif follow 1
Excel Need Countifs Formula Help 0
Countif/Vlookup 2
COUNTIF 3
=Countif(range, criteria) 2
Sorting and COUNTIF 6
Countif Based on Date Range 3

Back
Top