D
David
Hey All,
using the following vba code, i am trying to copy all the rows that have the
word "OK" on column A, example
i have data on row 1 to 20 and the following rows have "OK" on column A
rwo 2, row 5 and row 6, i want the macro to search for the word "OK" on
column A and copy the entire line inn sheet on the next empty row.
my current macro find the word "OK" however keeps copying the first line for
the number of "OK" it fined, in my example it will copy row 2 data three
times on sheet2.
Sub A()
Dim lastrow As Long
Dim r As Long
lastrow = Range("A" & Rows.Count).End(xlUp).row
For r = lastrow To 1 Step -1
If InStr(1, Cells(r, 1).Value, "OK") > 0 Then
Cells(r, 1).EntireRow.Select
Selection.Copy
Sheets("Sheet2").Select
Range("a1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Sheets("sheet1").Select
End If
Next
End Sub
Appreciate all the help
thanks
david
using the following vba code, i am trying to copy all the rows that have the
word "OK" on column A, example
i have data on row 1 to 20 and the following rows have "OK" on column A
rwo 2, row 5 and row 6, i want the macro to search for the word "OK" on
column A and copy the entire line inn sheet on the next empty row.
my current macro find the word "OK" however keeps copying the first line for
the number of "OK" it fined, in my example it will copy row 2 data three
times on sheet2.
Sub A()
Dim lastrow As Long
Dim r As Long
lastrow = Range("A" & Rows.Count).End(xlUp).row
For r = lastrow To 1 Step -1
If InStr(1, Cells(r, 1).Value, "OK") > 0 Then
Cells(r, 1).EntireRow.Select
Selection.Copy
Sheets("Sheet2").Select
Range("a1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Sheets("sheet1").Select
End If
Next
End Sub
Appreciate all the help
thanks
david