SumIf with variable ranges

pearl

New Member
Joined
Nov 3, 2010
Messages
14
I would like to sum column "E" based on what column "B" says. The range for column E will vary per run.

To sum column E without the Sumif looks like the following and works great.

<font face=Courier New> <SPAN style="color:#00007F">With</SPAN> ActiveCell<br>                    <SPAN style="color:#00007F">Set</SPAN> Rng = Range(.Offset(-mycount + 1), .End(xlUp))<br>                    .Formula = "=SUM(" & Rng.Address(RowAbsolute:=False, _<br>                   ColumnAbsolute:=False) & ")"<br>           <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN></FONT>

How do I change this to a sumif the associated row and column in B <> Exclude?

Thanks you
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
I'd imagine it'd be like this:
Code:
With ActiveCell
                    Set Rng = Range(.Offset(-mycount + 1), .End(xlUp))
                    Set Rng2 = Rng.Offset(0,-3)
                    .Formula = "=SUMIF(" & _
                   Rng2.Address(RowAbsolute:=False, _
                   ColumnAbsolute:=False) & _
                   ",""<>Exclude""," & _
                   Rng.Address(RowAbsolute:=False, _
                   ColumnAbsolute:=False) & ")"
           End With
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,223
Members
452,896
Latest member
IGT

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