Hi,
I want to revisit this macro with modified data. On the active sheet, "with_food", I tried to simply copy and paste the same macro and create a new macro and just change the columns to auto fill.
Here is the new code.
Sub autofill_row2()
Sub autofill_row2()
Dim i As Long, lrow As Long
With Worksheets("with_food")
lrow = .Range("G" & .Rows.Count).End(xlUp).Row
For i = 1 To lrow + 1
If .Range("G" & i) = "" Then
.Rows(i).Insert
.Range("G" & i - 1 & ":H" & i - 1).AutoFill Destination:=.Range("G" & i - 1 & ":H" & i), Type:=xlFillDefault
.Range("I" & i - 1).AutoFill Destination:=.Range("I" & i - 1 & ":O" & i), Type:=xlFillDefault
End If
Next i
End With
End Sub
The macro is not working properly and I would like, if possible if someone could both change the code so it autofills column G:G and then from I:O and maybe briefly explain how the code works.
Thanks
Sub autofill_row()
Dim i As Long, lrow As Long
With Worksheets("Sheet1")
lrow = .Range("D" & .Rows.Count).End(xlUp).Row
For i = 3 To lrow + 1
If .Range("D" & i) = "" Then
.Rows(i).Insert
.Range("D" & i - 1 & ":E" & i - 1).AutoFill Destination:=.Range("D" & i - 1 & ":E" & i), Type:=xlFillDefault
.Range("H" & i - 1).AutoFill Destination:=.Range("H" & i - 1 & ":H" & i), Type:=xlFillDefault
End If
Next i
End With
End Sub
Bookmarks