Sum cells above selected cell

AndyM90

New Member
Joined
Jul 25, 2014
Messages
47
Hi,

I am trying to create a macro to select the next blank cell in a column and sum the cells above it. However all the examples I can find on the internet dont seem to work.

The column is always column W, the row varies. So far I have the below which selects the cell I want the formula.

Code:
[COLOR=#333333]Range("W1").End(xldown).Offset(2,0).Select
[/COLOR]

now I want to sum the cells above this i.e. normally I could use the below if it is always a set range of rows. but it isn't as the amount of data varies daily.

Code:
ActiveCell.Formula = "=SUM(W1:W100)"


Any ideas how I can do this?

Thanks,

Andy
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Try:
Code:
ActiveCell.FormulaR1C1 = "=SUM(R1C:R[-1]C)"

Is the same as =SUM(A$1:A10) if entered in A11.

R1C is Row 1, this column.
R[-1]C is this row -1, this column.
 
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,755
Members
449,094
Latest member
dsharae57

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