Sub SearchForString()
Dim LSearchRow As Integer
Dim LCopyToRow As Integer
On Error GoTo Err_Execute
'Start search in row 3
LSearchRow = 3
'Start copying data to row 3 in Below10 (row counter variable)
LCopyToRow = 3
While Len(Range("A" & CStr(LSearchRow)).Value) > 0
'If value in column B = "Below10", copy entire row to Sheet2
If Range("B" & CStr(LSearchRow)).Value <= "10" Then
'Select row in Dashboard to copy
Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select
Selection.Copy
'Paste row into Below10 in next row
Sheets("Below10").Select
Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select
ActiveSheet.PasteSpecial
'Move counter to next row
LCopyToRow = LCopyToRow + 1
'Go back to Dashboard to continue searching
Sheets("Dashboard").Select
End If
LSearchRow = LSearchRow + 1
Wend
'Position on cell B3
Application.CutCopyMode = False
Range("B3").Select
MsgBox "All matching data has been copied."
Exit Sub
Err_Execute:
MsgBox "An error occurred."
End Sub
Bookmarks