Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to Stop a Macro if a 'Call' macro was used
Is ther a way to Cancel a CommandButton on a form via a Module Sub Routine ?
I can have : Userform1.CommandButon2.Cancel but it does not STOP the macro from running that called the other macro in the module, but returns an error. Is ther a way to STOP/CANCEL a CommandButton continuing from a Module code? Corey.... |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to Stop a Macro if a 'Call' macro was used
you'd have to code in the condition..........
if <condition then exit sub end if when it exits then it would go back to the first macro that called it. once it's in the middle of running the only way to break out of it is Ctrl+Break. hth :) susan On Jul 30, 7:25*am, "Corey" wrote: Is ther a way to Cancel a CommandButton on a form via a Module Sub Routine ? I can have : Userform1.CommandButon2.Cancel but it does not STOP the macro from running that called the other macro in the module, but returns an error. Is ther a way to STOP/CANCEL a CommandButton continuing from a Module code? Corey.... |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to Stop a Macro if a 'Call' macro was used
I do nto know how i can place an IF condition though. I use a : Sub CommandButton2_Click() 'code blah blah blah ........ Call Macro1 end Sub How would i place a condition in the Call Macro1 to Exit the CommandButton Sub IF the Macro1 Changes something? Corey.... "Susan" wrote in message ... you'd have to code in the condition.......... if <condition then exit sub end if when it exits then it would go back to the first macro that called it. once it's in the middle of running the only way to break out of it is Ctrl+Break. hth :) susan On Jul 30, 7:25 am, "Corey" wrote: Is ther a way to Cancel a CommandButton on a form via a Module Sub Routine ? I can have : Userform1.CommandButon2.Cancel but it does not STOP the macro from running that called the other macro in the module, but returns an error. Is ther a way to STOP/CANCEL a CommandButton continuing from a Module code? Corey.... |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to Stop a Macro if a 'Call' macro was used
you'd need some sort of a boolean value, then......
call Macro1 'then when it comes back to 'commandbutton2, check your 'boolean if myboolean = true then exit sub end if and in the macro1 sub, you'll need to set the boolean before you exit the macro1 sub......... if <condition then myboolean=true exit sub 'goes back to commandbutton2 here end if make sure your myboolean variable is a public variable, though, so it will carry over between the subs. hth susan On Jul 30, 8:24*am, "Corey" wrote: I do nto know how i can place an IF condition though. I use a : Sub CommandButton2_Click() 'code blah blah blah ....... Call Macro1 end Sub How would i place a condition in the Call Macro1 to Exit the CommandButton Sub IF the Macro1 Changes something? Corey.... "Susan" wrote in message ... you'd have to code in the condition.......... if <condition then exit sub end if when it exits then it would go back to the first macro that called it. *once it's in the middle of running the only way to break out of it is Ctrl+Break. hth :) susan On Jul 30, 7:25 am, "Corey" wrote: Is ther a way to Cancel a CommandButton on a form via a Module Sub Routine ? I can have : Userform1.CommandButon2.Cancel but it does not STOP the macro from running that called the other macro in the module, but returns an error. Is ther a way to STOP/CANCEL a CommandButton continuing from a Module code? Corey....- Hide quoted text - - Show quoted text - |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to Stop a Macro if a 'Call' macro was used
Thank you will give that a try.
"Susan" wrote in message ... you'd need some sort of a boolean value, then...... call Macro1 'then when it comes back to 'commandbutton2, check your 'boolean if myboolean = true then exit sub end if and in the macro1 sub, you'll need to set the boolean before you exit the macro1 sub......... if <condition then myboolean=true exit sub 'goes back to commandbutton2 here end if make sure your myboolean variable is a public variable, though, so it will carry over between the subs. hth susan On Jul 30, 8:24 am, "Corey" wrote: I do nto know how i can place an IF condition though. I use a : Sub CommandButton2_Click() 'code blah blah blah ....... Call Macro1 end Sub How would i place a condition in the Call Macro1 to Exit the CommandButton Sub IF the Macro1 Changes something? Corey.... "Susan" wrote in message ... you'd have to code in the condition.......... if <condition then exit sub end if when it exits then it would go back to the first macro that called it. once it's in the middle of running the only way to break out of it is Ctrl+Break. hth :) susan On Jul 30, 7:25 am, "Corey" wrote: Is ther a way to Cancel a CommandButton on a form via a Module Sub Routine ? I can have : Userform1.CommandButon2.Cancel but it does not STOP the macro from running that called the other macro in the module, but returns an error. Is ther a way to STOP/CANCEL a CommandButton continuing from a Module code? Corey....- Hide quoted text - - Show quoted text - |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How can run a macro ( call a macro) on selection of any filtercriteria? | Excel Worksheet Functions | |||
Excel Macro call Word Macro with Parameters | Excel Programming | |||
Call macro stored in Excel workbook from Outlook's macro | Excel Programming | |||
Can't call up floating macro toolbar-stop recording/relative ref. | Excel Programming | |||
Start Macro / Stop Macro / Restart Macro | Excel Programming |