![]() |
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. |
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. |
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. |
Stopping a series of macros
Hi Harold and Tim,
Thanks for your replies, which sloved my problem. Regards - Dave. |
All times are GMT +1. The time now is 10:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com