![]() |
ending vba
I am sure this is super simple but cannot find it anywhere.
I am running subs that call on a list of other subs, I want to test something and stop vba from running. So far it just exits the sub I am in and continues to run the next sub. How do I shut down VBA completly and take user back to the Excel Spreadsheet? If PName = "" Then x = MsgBox("You must enter a Participant Name", vbCritical, "Error") Application.Goto Sheets("Program Controls").Range("ParticipantName"), True 'Here I want to stop running ALL VBA code not just this subroutine End If |
ending vba
You could use
End -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Arnold Klapheck" wrote in message ... I am sure this is super simple but cannot find it anywhere. I am running subs that call on a list of other subs, I want to test something and stop vba from running. So far it just exits the sub I am in and continues to run the next sub. How do I shut down VBA completly and take user back to the Excel Spreadsheet? If PName = "" Then x = MsgBox("You must enter a Participant Name", vbCritical, "Error") Application.Goto Sheets("Program Controls").Range("ParticipantName"), True 'Here I want to stop running ALL VBA code not just this subroutine End If |
ending vba
You could change your subs into functions that return booleans. Something
like this... sub DoLotsOfStuff if DoThis = false then exit sub if DoThat = false then exit sub msgbox "Everything went ok" end sub Function DoThis() as boolean DoThis = True if False then DoThis = False exit function end if End Function Function DoThat() as boolean DoThat= True if true then DoThat= False exit function end if End Function -- HTH... Jim Thomlinson "Arnold Klapheck" wrote: I am sure this is super simple but cannot find it anywhere. I am running subs that call on a list of other subs, I want to test something and stop vba from running. So far it just exits the sub I am in and continues to run the next sub. How do I shut down VBA completly and take user back to the Excel Spreadsheet? If PName = "" Then x = MsgBox("You must enter a Participant Name", vbCritical, "Error") Application.Goto Sheets("Program Controls").Range("ParticipantName"), True 'Here I want to stop running ALL VBA code not just this subroutine End If |
ending vba
You should note that End clears any global variables and objects... This may
or may not be an issue. -- HTH... Jim Thomlinson "Bob Phillips" wrote: You could use End -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Arnold Klapheck" wrote in message ... I am sure this is super simple but cannot find it anywhere. I am running subs that call on a list of other subs, I want to test something and stop vba from running. So far it just exits the sub I am in and continues to run the next sub. How do I shut down VBA completly and take user back to the Excel Spreadsheet? If PName = "" Then x = MsgBox("You must enter a Participant Name", vbCritical, "Error") Application.Goto Sheets("Program Controls").Range("ParticipantName"), True 'Here I want to stop running ALL VBA code not just this subroutine End If |
ending vba
thanks, I knew it would be simple, I was thinking I had to put something
after end. |
All times are GMT +1. The time now is 01:26 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com