I'm using a code I found for copying several rows from sheet1 to sheet2 if one cell in column "A" contains 1 of 4 text options for example "name", "school", "class", "team"
The coding is pretty new to me. So I'm straggling to get the results I need:
As for the code I've found - everytime I run it, another (unnecessary) of the same rows are popping, and I'm not sure how to include the other 3 text condition.
The code I'm using:
Option Explicit
Sub Test()
Dim Cell As Range
With Sheets(1)
' loop column A untill last cell with value (not entire column)
For Each Cell In .Range("A1:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
If Cell.Value = "name" Then
' Copy>>Paste in 1-line (no need to use Select)
.Rows(Cell.Row).Copy Destination:=Sheets(2).Rows(Cell.Row)
End If
Next Cell
End With
End Sub
The coding is pretty new to me. So I'm straggling to get the results I need:
As for the code I've found - everytime I run it, another (unnecessary) of the same rows are popping, and I'm not sure how to include the other 3 text condition.
The code I'm using:
Option Explicit
Sub Test()
Dim Cell As Range
With Sheets(1)
' loop column A untill last cell with value (not entire column)
For Each Cell In .Range("A1:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
If Cell.Value = "name" Then
' Copy>>Paste in 1-line (no need to use Select)
.Rows(Cell.Row).Copy Destination:=Sheets(2).Rows(Cell.Row)
End If
Next Cell
End With
End Sub