Example
I have spreadsheet(Sheet2) like
I need to search "Tran1" and "app" full row data from my excel-sheet and after searching the record I need to copy the rows into Sheet3.
Currently I am able to do it only for 1 record "Tran1" but i need to do it with multiple values.
Here is my code snippet:
Dim LSearchRow As Integer
Dim LCopyToRow As Integer
On Error GoTo Err_Execute
LSearchRow = 4
LCopyToRow = 2
While Len(Range("A" & CStr(LSearchRow)).Value) > 0
If InStr(1, Range("A" & CStr(LSearchRow)).Value, "tran1") > 0 Then
'Select row in Sheet2 to copy
Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select
Selection.Copy
'Paste row into Sheet3 in next row
Sheet3.Select
Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select
ActiveSheet.Paste
'Move counter to next row
LCopyToRow = LCopyToRow + 1
'Go back to Sheet2 to continue searching
Sheet2.Select
End If
LSearchRow = LSearchRow + 1
Wend
'Position on cell A3
Application.CutCopyMode = False
Range("A3").Select
MsgBox "All matching data has been copied."
Exit Sub
Err_Execute:
MsgBox "An error occurred."
Can anyone let me tell how to do with multiple search.?