ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Sumif from VBA Type mismatch (https://www.excelbanter.com/excel-worksheet-functions/133843-sumif-vba-type-mismatch.html)

mdalamers via OfficeKB.com

Sumif from VBA Type mismatch
 
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.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...tions/200703/1


Dave Peterson

Sumif from VBA Type mismatch
 
Check your other post.

"mdalamers via OfficeKB.com" wrote:

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.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...tions/200703/1


--

Dave Peterson

Martin Fishlock

Sumif from VBA Type mismatch
 
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


--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"mdalamers via OfficeKB.com" wrote:

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.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...tions/200703/1



mdalamers via OfficeKB.com

Sumif from VBA Type mismatch
 
Thanks Martin. That worked well!

Now I can finally go home!

M.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...tions/200703/1



All times are GMT +1. The time now is 01:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com