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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,216,028
Messages
6,128,399
Members
449,446
Latest member
CodeCybear

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