View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
achidsey achidsey is offline
external usenet poster
 
Posts: 100
Default End sub early if mismatch


Gary''s Student,

Simple enough.

Thanks

--
achidsey


"Gary''s Student" wrote:

Exit Sub
--
Gary''s Student


"achidsey" wrote:


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

--
achidsey