What I am trying to achieve is to search a list of texts in column G with column B of the same excel sheet (Sheet1) and if any match occurs then that whole row must be copied and paste it in another sheet(Sheet2). Actually I have tried a lot to debug the code but it is not working. Any help would be greatly appreciated! I have attached the code below.
Thank You Anuj
Sub SearchForString()
   Dim LSearchRow As Integer
   Dim LCopyToRow As Integer
   Dim searchTerm As String
   On Error GoTo Err_Execute
   LSearchRow = 2
   LCopyToRow = 2
  For i = 2 To 15
      searchTerm = Range("G" & i).Text
      If Range("B" & CStr(LSearchRow)).Value = searchTerm Then
         Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select
         Selection.Copy
         Sheets("Sheet2").Select
         Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select
         ActiveSheet.Paste
         LCopyToRow = LCopyToRow + 1
         Sheets("Sheet1").Select
      End If
Next i
LSearchRow = LSearchRow + 1
   Application.CutCopyMode = False
   Range("A3").Select
   MsgBox "All matching data has been copied!"
   Exit Sub
Err_Execute:
   MsgBox "An error occurred!"
End Sub
 
     
    