I am making a program that compares two companies and it contains 500 lines of data. I want a message box to appear when the user types an invalid name but the problem is that the error message box comes up 500 times when I need it to come up once. Can anyone help??
Sub FindCompany()
Dim companyname As String
Dim finalrow As Integer
Dim i As Integer
Sheets("CompanyRatings").Activate
companyname = InputBox("Enter the Company Name :")
finalrow = Sheets("CompanyRatings").Range("A1000").End(xlUp).Row
For i = 2 To finalrow
If Cells(i,1) = companyname Then
Range(Cells(i, 1), Cells(i, 9)).Copy
Sheets("FrontPage").Activate
Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
ElseIf Cells(i,1) <> companyname Then
result = MsgBox("Invalid Input", vbOKOnly, "Error Encountered")
End If
Next i
End Sub
Bookmarks