createing a running sum in VBA

fares paris

New Member
Joined
Jun 5, 2013
Messages
3
Bonjour,

Ihave beeen struggling on this for way too long, I'm trying to create a running total. fist the macro starts by inserting a column and calls its first cell Incremental cost, then the cell bellow is set to be equal to the adjacent cell, the one below is equal the sum of the one above and the adjacent. now this is where I have the problem I auto fill this range to the cells below and then copy this colunm and paste it in a new sheet. I have encountered several problems with different methods.
with inputing an equation such as
"=RC[-1]+R[-1]C"
it works until I copy the colunmin to a new sheet , in this case only the equations gets copied and not the values.
In the other case posted belowI end up adding theses two specific cells over an over again.

here is the last code I used, all help would be kindly appreciated.

Sub IncCost()

Dim r As Range
Set r = ActiveSheet.Range("A1").CurrentRegion
Columns("H:H").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("H1").FormulaR1C1 = "Incremental cost"
Range("H2").FormulaR1C1 = Cells(2, 7)
Range("H3").FormulaR1C1 = "=" & Cells(3, 7) & "+" & Cells(2, 8)
Range("H3").AutoFill Destination:=Range("H3:H" & r.Rows.Count)

End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,215,836
Messages
6,127,179
Members
449,368
Latest member
JayHo

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