Hey guys!
First the code:
So I have this to add two columns and populate with formulas for the entire worksheet
The code runs fine, and adds the columns but does not add the formulas. Is there something I'm missing?
Thanks,
M
First the code:
Code:
Sub MyInsertColumn()
Dim wks As Worksheet
Dim i As Long
Dim Lastrow As Long
Application.ScreenUpdating = False
Lastrow = Range("A" & Rows.Count).End(xlUp).Row
For Each wks In ActiveWindow.SelectedSheets
With wks
For i = .Cells.SpecialCells(xlCellTypeLastCell).Column To 2 Step -1
.Columns(i).Insert
Range(Cells(2, i), Cells(Lastrow, i)).Formula = "=SUM(a2,b2)"
.Columns(i).Insert
Range(Cells(2, i), Cells(Lastrow, i)).Formula = "=SUM(a2,b2)"
Next i
End With
Next wks
End Sub
So I have this to add two columns and populate with formulas for the entire worksheet
The code runs fine, and adds the columns but does not add the formulas. Is there something I'm missing?
Thanks,
M