End sub early if mismatch

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My code (below) uses a For Each..Next loop with an If section to check if
two columns of data match.

If there is a mismatch, code displays a message box.

I want to add a line that ends the procedure if a mismatch is found.

What code would do this?


Sub CompareLists()

Cells.Find(What:="Open Positions In Current Year").Offset(1).Select
Range(Selection, Selection.End(xlDown)).Select

Set CurSymbols = Selection

Cells.Find(What:="PASymbol").Select
Set PASymbol = Selection

For Each Sym In CurSymbols

If Sym <> Cells(Sym.Row, PASymbol.Column) Then

MsgBox "Mismatch on " & Sym

'*** Add code here to end procedure if there is a mismatch***


End If

Next Sym

MsgBox "Symbol Lists Match"

End Sub


Thanks in advance,
Alan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top