![]() |
End sub early if mismatch
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 |
End sub early if mismatch
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 |
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 |
All times are GMT +1. The time now is 12:15 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com