Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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
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 can run a macro ( call a macro) on selection of any filtercriteria? [email protected] Excel Worksheet Functions 7 February 20th 09 12:34 AM
Excel Macro call Word Macro with Parameters Bill Sturdevant[_2_] Excel Programming 9 May 24th 07 12:21 AM
Call macro stored in Excel workbook from Outlook's macro Gvaram Excel Programming 0 October 4th 06 05:47 PM
Can't call up floating macro toolbar-stop recording/relative ref. tjohn176 Excel Programming 2 December 9th 03 07:22 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 01:27 AM.

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

About Us

"It's about Microsoft Excel"