I am a very beginner in VBA. I would like to automatically copy and paste if a certain condition is met. If Row G is "N" then copy from Range(Cells(Row+1,"h"), Cells(Row,"bg")) and paste to Range(Cells(Row+1,"h"), Cells(Row,"bg")) and add "Data substituted" in the substituted Row "bh". There are codes I've been made so far, '13' runtime error occurs whenever I implemented the code below. I am very lost please help me! Thank you in advance.
Sub Sbustitute()
Dim nRows As Long, LastRow As Long, Row As Long, Column As Range, Color As Long
nRows = 2
LastRow = Cells(Rows.Count, "b").End(xlUp).Row
For Row = LastRow To nRows Step -1
Set Cell = Cells(Row, "g")
If Cell = "N" Then
Range(Cells(Row + 1, "h"), Cells(Row + 1, "bg")).Copy Range(Cells(Row, "h"), Cells(Row, "bg"))
ActiveSheet.Paste
Cells(Row, "bh") = "Data substituted"
End If
Next
End Sub
Aucun commentaire:
Enregistrer un commentaire