Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,388
Default Stopping a series of macros

Hi,
XL2000
I have a macro which calls a bunch of other macro's in order.

Sub DoAll()
Application.ScreenUpdating = False
Call ImportData
Call PasteRelevantImportData
Call ConcatonateComments
Call SortInitial
Call GroupDups
Call BestGuessColB
Call BestGuessColD
Call SortFinal
Application.ScreenUpdating = True
End Sub

Some of the macros contain error handling lines like:
If such-and-such Then Exit Sub.
So that particular Sub ends, and the DoALL macro calls the next Sub.
I need a line of code that will actually stop the DoAll macro, not just the
one that is executing at the time. Is this possible?

Regards - Dave.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Stopping a series of macros

You could use a global boolean to track success of each step

Eg:

Dim bStop as boolean

Sub DoAll()
bStop=False
Call ImportData
If not bStop then Call PasteRelevantImportData
.....
End Sub

where bStop might be set in ImportData before the Exit Sub statement.

Or switch your subs to functions and test the return values.

Tim


"Dave" wrote in message
...
Hi,
XL2000
I have a macro which calls a bunch of other macro's in order.

Sub DoAll()
Application.ScreenUpdating = False
Call ImportData
Call PasteRelevantImportData
Call ConcatonateComments
Call SortInitial
Call GroupDups
Call BestGuessColB
Call BestGuessColD
Call SortFinal
Application.ScreenUpdating = True
End Sub

Some of the macros contain error handling lines like:
If such-and-such Then Exit Sub.
So that particular Sub ends, and the DoALL macro calls the next Sub.
I need a line of code that will actually stop the DoAll macro, not just
the
one that is executing at the time. Is this possible?

Regards - Dave.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default Stopping a series of macros

Hi Dave

You want your Sub to return a result (like successful, something like that).
Make it a function, a Sub is nothing but a function returning nothing:

Function ImportData() As Boolean
'importing, do stuff, then check
If Data.Count 0 then 'or whatever, success, we have data:
ImportData = True
end if
End Function

And then in Doall:

Sub DoAll()
If ImportData = False Then Exit Sub
If PasteRelevantImportData = False Then Exit Sub
and so on, as needed

HTH. Best wishes Harald

"Dave" wrote in message
...
Hi,
XL2000
I have a macro which calls a bunch of other macro's in order.

Sub DoAll()
Application.ScreenUpdating = False
Call ImportData
Call PasteRelevantImportData
Call ConcatonateComments
Call SortInitial
Call GroupDups
Call BestGuessColB
Call BestGuessColD
Call SortFinal
Application.ScreenUpdating = True
End Sub

Some of the macros contain error handling lines like:
If such-and-such Then Exit Sub.
So that particular Sub ends, and the DoALL macro calls the next Sub.
I need a line of code that will actually stop the DoAll macro, not just
the
one that is executing at the time. Is this possible?

Regards - Dave.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,388
Default Stopping a series of macros

Hi Harold and Tim,
Thanks for your replies, which sloved my problem.
Regards - Dave.
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
Macros cells.EntireRow.Hidden = True and Range.Sort are stopping Adrian Excel Programming 0 March 22nd 06 01:59 AM
Stopping automatic macros Yorke Excel Programming 1 November 1st 05 08:53 PM
Stopping macros running? Ben Vince UK Excel Programming 2 April 19th 05 04:51 PM
stopping the link of macros in one workbook with every other exce. KyWilde Excel Discussion (Misc queries) 0 March 10th 05 06:35 PM
stopping the link of macros in one workbook with every other exce. KyWilde Excel Discussion (Misc queries) 0 March 10th 05 06:35 PM


All times are GMT +1. The time now is 12:48 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"