Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
formula help - avtive early j5b9721 Excel Worksheet Functions 0 August 28th 09 04:42 AM
15 minutes early Glenn_H Excel Discussion (Misc queries) 4 January 31st 08 06:44 PM
Early Login, Last Logout junoon Excel Worksheet Functions 3 May 9th 07 04:04 PM
Macros terminate early Pierre[_3_] Excel Programming 5 January 23rd 04 05:54 PM
Loop ends early BrianB Excel Programming 0 August 15th 03 12:13 PM


All times are GMT +1. The time now is 12:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"