LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Using "End" to stop all code

Excel 2002, WinXP

I have seen dire warnings in these newsgroups about using the "End"
statement to stop all code execution and I understand the reasons for the
warnings and have never used it. But I have a unique instance where it
would be very handy to use it and I think I am safe in doing so, but I want
to pass it by some of you to see if I am overlooking something.

The program consists of looping through some 150 sheets and
performing some 30 different procedures on each sheet and everything is
working well. Five of these procedures call the "SetDest" procedure. The
SetDest procedure searches for some text in the sheet. The problem comes
about if that text cannot be found in that sheet. The OP I am helping wants
the code to stop if that occurs and revert back to the file as it was before
anything was done to it by this program.

What I propose to do is put the following in the SetDest macro: (Ignore
syntax)

If ..cannot be found Then

MsgBox "Explain what happened & to which sheet and what will
happen now."

ActiveWorkbook.Close (display alerts = False)

TheFile.Open (same file)

End

End If



Do any of you see me stepping in something I don't like?

Can I add some code to make it safer?

Should I close and reopen Excel and then open TheFile?

Thanks for your help. Otto


 
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
How stop the "started office live" pop-up to stop. it is checked yrose24 Excel Discussion (Misc queries) 1 September 2nd 09 03:32 PM
How do I stop "global" hyperlinks changing to "local" links? Em Excel Worksheet Functions 2 August 26th 08 01:18 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Looking for VB code to test for "RING" , "BUSY" disconnects or other signals BruceJ[_2_] Excel Programming 3 November 20th 03 01:55 AM


All times are GMT +1. The time now is 01:15 PM.

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

About Us

"It's about Microsoft Excel"