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
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