Hi Phil
Try the following code - it uses Autofilter which removes the need to loop (and can be very fast).
You will need to amend the wsFrom and wsTo names as indicated in the code, potentially the TO_FIND constant if you choose a different search term and also the Range (G71:G86 currently) if you wqant to extend the data rows being examined./
Sub copy_data()
Const TO_FIND = "Lost" 'amend as required
Dim rng As Range
Dim wsFrom As Worksheet, wsTo As Worksheet
Dim lngCalc As Long
With Application
lngCalc = .Calculation
.Calculation = xlCalculationManual
End With
Set wsFrom = Sheets("Sheet2") 'amend as appropriate (this is the name of the sheet you are copying data FROM)
Set wsTo = Sheets("Sheet1") 'amend as appropriate (this is the name of the sheet you are copying data TO)
With wsFrom
.AutoFilterMode = False
Set rng = .Range("G71:G86") 'this is the range that contains the data - amend as appropriate
End With
With rng
.Cells(1, 1).EntireRow.Insert
.Offset(-1).Resize(1).Value = "TempHeader"
.Resize(.Rows.Count + 1).Offset(-1).AutoFilter field:=1, Criteria1:=TO_FIND
.EntireRow.Copy
With wsTo.Cells(Rows.Count, "A").End(xlUp).Offset(1)
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
End With
.AutoFilter
.Offset(-1).Resize(1).EntireRow.Delete 'delete temp hdr row
End With
Application.Calculation = lngCalc
End Sub
Richard
Bookmarks