SUMIF using named range

coop123

Board Regular
Joined
Dec 18, 2018
Messages
66
Office Version
  1. 365
Hi

I am trying to add a sumif formula to an existing macro. I am wanting to sum all minus values and all positive values. The start and end of the range being summed will change each time report is downloaded.

I have got to the top of my column of data as part of existing macro.

Dim Rng As Range
Set Rng = ActiveCell.End(xlDown)

Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveCell.Resize(4, 1).Select
Selection.Delete Shift:=xlUp

ActiveCell.Resize(1, 1).Select

ActiveCell.Offset(1, 1).Select

ActiveCell.FormulaR1C1 = "=SUMIF(Rng:R[-2]C2,"">0"",Rng:R[-2]C)"

Actual SUMIF formula is =SUMIF(B23:B40,"<0",B23:B40). Range B23:B40 will vary each time report is run.

Any help to correct my formula would very much be appreciated.

Thank you

Coop123
 
You are welcome.
Glad I was able to help!
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,215,084
Messages
6,123,029
Members
449,092
Latest member
ikke

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