I'm looking to modify the code below that I received from this forum so that it copies to the next available row on Sheet 5.
Private Sub CommandButton1_Click()
Dim Cell As Range
With Sheets(1)
' loop column H untill last cell with value (not entire column)
For Each Cell In .Range("H1:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If Cell.Value = "YES" Then
' Copy>>Paste in 1-line (no need to use Select)
.Rows(Cell.Row).Copy Destination:=Sheets(5).Rows(Cell.Row)
End If
Next Cell
End With
End Sub
This following code worked for the copy over to the next available row, however If I kept clicking the commandbutton it would keep pasting the information over and over again. It also did not keep the source formatting and formulas, only copied the text. I don't want it to duplicate in the destination sheet and I would like it to copy over the formatting and formulas
Private Sub CommandButton1_Click()
Dim Cell As Range
With Sheets(1)
' loop column H untill last cell with value (not entire column)
For Each Cell In .Range("H1:H" & .Cells(.Rows.Count, "H").End(xlUp).Row)
If Cell.Value = "Matt Stephens" Then
.Range("A" & Cell.Row & ":Q" & Cell.Row).Copy
' Paste as Links requires to select a destination cell
Sheets(5).Range("A" & Sheets(5).Cells(Sheets(5).Rows.Count, "A").End(xlUp).Row + 1).Select
ActiveSheet.Paste Link:=True
End If
Next Cell
End With
End Sub
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…