I'm new to vba and I'm trying to copy a row (if it features the value "2020" in column G" and insert it right below the copied row). And then I need to replace the "2020" value with "2021" in the new created row. I also need to replace the value in column A with the value from the copied row multiplied by a number from a different cell. These are the parts I'm struggling with.
I have up to the new created and copied row.
Sub Test()
Dim iLastRow As Long
Dim i As Long
iLastRow = Cells(Rows.Count, "G").End(xlUp).Row
For i = iLastRow To 1 Step -1
If Cells(i, "G").Value = "2020" Then
Rows(i).Copy
Rows(i + 1).Insert
End If
Next i
End Sub
Thanks.
I have up to the new created and copied row.
Sub Test()
Dim iLastRow As Long
Dim i As Long
iLastRow = Cells(Rows.Count, "G").End(xlUp).Row
For i = iLastRow To 1 Step -1
If Cells(i, "G").Value = "2020" Then
Rows(i).Copy
Rows(i + 1).Insert
End If
Next i
End Sub
Thanks.