Converting SumIf to VBA - Type Mismatch error

Phitur

New Member
Joined
Jul 23, 2010
Messages
21
I'm trying to convert this formula to VBA code:
PHP:
=SUMIF(I:I,N3,G:G)
Code:
Cells(i, col6).Value = Application.SumIf(Range(col1 & _
  Chr(58) & col1), Cells(i, col2), (Range("G:G")))
Where col1 = "I"
col2 = "N"
i = 3

I get a type mismatch error in VBA; however, the formula runs fine in Excel. How do I resolve this problem?

Thanks
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Not sure WHY this is the problem...

But when I run it like this it errors

Rich (BB code):
Cells(i, col6).Value = Application.SumIf(Range(col1 & _
  Chr(58) & col1), Cells(i, col2), (Range("G:G")))

If I run it like this, it works
Rich (BB code):
Cells(i, col6).Value = Application.SumIf(Range(col1 & _
  Chr(58) & col1), Cells(i, col2), Range("G:G"))

Again, not sure why....
 
Upvote 0
Dang. I completely overlooked that. I found that in my research this morning too and knew you couldn't do that.

Thanks!
 
Upvote 0

Forum statistics

Threads
1,216,089
Messages
6,128,750
Members
449,466
Latest member
Peter Juhnke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top