I keep getting a compiling error: Loop without Do
even though I wrote Do
in my code. What am I missing?
Sub SearchForString()
Dim StartCell As Integer
Dim EndCell As Integer
StartCell = 2
EndCell = 545
Do While StartCell < EndCell
Sheets("tian_corp_donations_Aug2019_how").Activate
Sheets("tian_corp_donations_Aug2019_how").Select
With ThisWorkbook.Worksheets("tian_corp_donations_Aug2019_how")
'If value in column E = "Company_Name", copy entire row to Sheet2
If Range("B:StartCell").Value = "George Weston Limited" Then
'Select row in Sheet1 to copy
Rows(StartCell).Select
Selection.Copy
'Paste row into Sheet2 in next row
Sheets("Sheet2").Select
Rows(StartCell).Select
ActiveSheet.Paste
'Move counter to next row
'LCopyToRow = LCopyToRow + 1
Exit Do
End If
'Go back to Sheet1 to continue searching
Sheets("tian_corp_donations_Aug2019_how").Select
StartCell = StartCell + 1
Loop
End Sub