I am trying to create an Excel macro that does the following:
Enter a new line at the end of document
copy the formulas from the cells above
So far I have this:
Sub New_Delta()
' Go to last cell
Range("A4").Select
Selection.End(xlDown).Select
LastCell = [A65536].End(xlUp).Offset(-1, 0).Address
Range(LastCell).Select
' Enter new line
Selection.EntireRow.Insert Shift:=xlUp, CopyOrigin:=xlFormatFromLeftOrAbove
' Copy formula from cell above
Dim oCell As Range
For Each oCell In Selection
If (oCell.Value = "") Then
oCell.Offset(-1, 0).Copy Destination:=oCell
End If
Next oCell
End Sub
This copies the formula for the first cell "A" but not the following ones
I want to do something like Selection.Offset(0, 1).Select
and then iterate over that up to "K" (preferably without "G" and "H")
But I'm stuck, and could really use some help.
EDIT: I want something like this (Non working pseudo code)
' Copy formula from cell above
Dim oCell As Range
While (oCell.Offset(-1, 0).Value != "") ' If the cell above is not empty
oCell.Offset(-1, 0).Copy Destination:=oCell ' Copy the formula from the cell above
Selection.Offset(0, 1).Select ' Move one cell to the right