Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default One macro two versions

I have a macro which is normally invoked by a button on a worksheet. Before
the macro is run, there is a MsgBox prompt asking for confirmation.

Now I want to call this macro from another macro. In this case, I want to
skip the MsgBox prompt part and go ahead with the macro right away.

How can I check whether the macro has been called by a button or another
macro? Or is there a better way handling this problem?

TIA

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default One macro two versions

Hi Shatin

Look in the VBA help for application.caller if you use forms buttons


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Shatin" wrote in message ...
I have a macro which is normally invoked by a button on a worksheet. Before
the macro is run, there is a MsgBox prompt asking for confirmation.

Now I want to call this macro from another macro. In this case, I want to
skip the MsgBox prompt part and go ahead with the macro right away.

How can I check whether the macro has been called by a button or another
macro? Or is there a better way handling this problem?

TIA

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default One macro two versions

I would have the code for the button be something simple such as

response = msgbox("Do you want to run the macro....")
If response = vbYes then
Call MacroName
Endif

The you can still call MacroName from another macro that does not require
the user to respond to the message box prompt.

"Shatin" wrote:

I have a macro which is normally invoked by a button on a worksheet. Before
the macro is run, there is a MsgBox prompt asking for confirmation.

Now I want to call this macro from another macro. In this case, I want to
skip the MsgBox prompt part and go ahead with the macro right away.

How can I check whether the macro has been called by a button or another
macro? Or is there a better way handling this problem?

TIA


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default One macro two versions

Actually I simplified the situation somewhat when I posed the question. In
fact I have buttons on several worksheets that call the same macro. So
application.caller doesn't always return the same unique button name. I was
hoping that something like this might work

If application.caller.name like "button*"

but apparently not.

"Ron de Bruin" wrote in message
...
Hi Shatin

Look in the VBA help for application.caller if you use forms buttons


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Shatin" wrote in message
...
I have a macro which is normally invoked by a button on a worksheet.
Before the macro is run, there is a MsgBox prompt asking for confirmation.

Now I want to call this macro from another macro. In this case, I want to
skip the MsgBox prompt part and go ahead with the macro right away.

How can I check whether the macro has been called by a button or another
macro? Or is there a better way handling this problem?

TIA


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default One macro two versions

That is a simple and practical solution and maybe that's what I am actually
going to do. Still, I am curious to know what
the code would be like if I want to have just one macro.

"BigJimmer" wrote in message
...
I would have the code for the button be something simple such as

response = msgbox("Do you want to run the macro....")
If response = vbYes then
Call MacroName
Endif

The you can still call MacroName from another macro that does not require
the user to respond to the message box prompt.

"Shatin" wrote:

I have a macro which is normally invoked by a button on a worksheet.
Before
the macro is run, there is a MsgBox prompt asking for confirmation.

Now I want to call this macro from another macro. In this case, I want to
skip the MsgBox prompt part and go ahead with the macro right away.

How can I check whether the macro has been called by a button or another
macro? Or is there a better way handling this problem?

TIA



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
Macro in Different Versions of Excel Valli Excel Programming 4 October 25th 07 05:08 PM
help i want to use old vb macro(excel95)with later versions usf85[_2_] Excel Programming 1 May 2nd 06 06:53 PM
Macro compatibiltiy between XL versions [email protected] Excel Programming 1 April 18th 06 07:03 PM
Please include fonts from previous versions ('98) in new versions JJBQ Excel Discussion (Misc queries) 3 October 8th 05 07:19 PM
VBA Macro Versions ACFalcon Excel Programming 5 September 10th 05 02:56 AM


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