Sumif from VBA Type mismatch

  • Thread starter Thread starter mdalamers via OfficeKB.com
  • Start date Start date
M

mdalamers via OfficeKB.com

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.
 
Check your other post.

mdalamers via OfficeKB.com said:
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.
 
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
 
Back
Top