Please help me.
I try to run a SUMIF worksheet function from my VBA code.
Basically this is the troublesome line.
MsgBox Application.WorksheetFunction.SumIf("$E$1:$E$226", ">0", "$N$1:$N$224")
When I run it, Excel gives me a compile error, type mismatch, highlighted on:
"$E$1:$E$226"
What am I doing wrong?
Regards,
Michiel.
Dave Peterson - 07 Mar 2007 23:19 GMT
Check your other post.
> Please help me.
>
[quoted text clipped - 15 lines]
> Message posted via OfficeKB.com
> http://www.officekb.com/Uwe/Forums.aspx/excel-functions/200703/1

Signature
Dave Peterson
Martin Fishlock - 07 Mar 2007 23:26 GMT
You need to qualify the address using a range object as in if you are using
the activesheet:
MsgBox Application.WorksheetFunction.SumIf( _
Range("$E$1:$E$226"), ">0", Range("$N$1:$N$224"))
End Sub

Signature
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.
> Please help me.
>
[quoted text clipped - 11 lines]
>
> Michiel.
mdalamers - 07 Mar 2007 23:56 GMT
Thanks Martin. That worked well!
Now I can finally go home!
M.