countif in VBA

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
 
B

Bob Phillips

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)
 
N

nyn04

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
 
B

Bob Phillips

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)
 
Top