I have this Macro in excel and can not figure out how to set the formula to devide a cell by the last column.
Currently, this line divides the cell by a number, (in my case it is 12 since I have 12 columns)
Cells(LastRow - 1, i + 1).FormulaR1C1 = "=RC[-1]/" & (LastColumn)
Thank you
Code:
Sub (Test)
Application.ScreenUpdating = False
Dim LastColumn, LastRow As Integer
Cells.MergeCells = False
Rows("1:3").Delete Shift:=xlUp
Columns("A:A").Delete Shift:=xlToLeft
LastColumn = Range("IV1").End(xlToLeft).Column
LastRow = Range("A65536").End(xlUp).Row + 1
For i = 2 To (LastColumn + LastColumn - 1) Step 2
Columns(i + 1).Insert
Cells(1, i + 1).Value = "% of Grth"
Columns(i + 1).NumberFormat = "0%"
''
LastColumn = Range("IV1").End(xlToLeft).Column
'''
Cells(LastRow - 1, i + 1).FormulaR1C1 = "=RC[-1]/" & (LastColumn)
Cells(LastRow - 1, i + 1).Select
Selection.AutoFill Destination:=Range(Cells(2, i + 1), Cells(LastRow - 1, i + 1)), Type:=xlFillDefault
Next i
Columns(LastColumn + LastColumn - 1).Delete
End sub