ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Assign several macros with OnAction (https://www.excelbanter.com/excel-programming/367648-assign-several-macros-onaction.html)

[email protected]

Assign several macros with OnAction
 
Hi,

I have created some CommandBarButtons. I assign which macro to run when
selecting the menu item by using the OnAction property.
myMenyItem.onAction = "updateData"

I would like two run several macros instead of one, in fashion og
myMenyItem.onAction = "updateData1 : updateData2 : updateScreen"

where updateData1, updateData2, updateScreen are three different subs.
Is this possible?

Best Regards
Eric


colofnature[_92_]

Assign several macros with OnAction
 

Try creating a wrapper sub which calls the three: e.g.

...
myMenyItem.onAction = "WrapperSub"
...

sub WrapperSub()
updateData1
updateData2
updateScreen
end sub


Co

--
colofnatur
-----------------------------------------------------------------------
colofnature's Profile: http://www.excelforum.com/member.php...fo&userid=3435
View this thread: http://www.excelforum.com/showthread.php?threadid=56278


NickHK

Assign several macros with OnAction
 
You can one macro form another:
Sub updateData()
Call updateData1
Call updateData2
Call updateScreen
End sub



wrote in message
ups.com...
Hi,

I have created some CommandBarButtons. I assign which macro to run when
selecting the menu item by using the OnAction property.
myMenyItem.onAction = "updateData"

I would like two run several macros instead of one, in fashion og
myMenyItem.onAction = "updateData1 : updateData2 : updateScreen"

where updateData1, updateData2, updateScreen are three different subs.
Is this possible?

Best Regards
Eric




[email protected]

Assign several macros with OnAction
 

NickHK wrote:
You can one macro form another:
Sub updateData()
Call updateData1
Call updateData2
Call updateScreen
End sub

[...]

Yes, I know I can do it like this, but since I have a lot of
permutations of how to run the macros (macro1 - macro3 - macro2,
macro3 - macro1, et.c) I would be happy if I did not have to clutter
the workbook with a lot of macros.

Like an if-then, you can write it on one row and separate expressions
with ":".

Best Regards
Eric


NickHK

Assign several macros with OnAction
 
If it really matters to you to confuse the coding in order to save a few
lines:
Sub updateData()
updateData1: updateData2: updateScreen
End sub

NickHK

wrote in message
ups.com...

NickHK wrote:
You can one macro form another:
Sub updateData()
Call updateData1
Call updateData2
Call updateScreen
End sub

[...]

Yes, I know I can do it like this, but since I have a lot of
permutations of how to run the macros (macro1 - macro3 - macro2,
macro3 - macro1, et.c) I would be happy if I did not have to clutter
the workbook with a lot of macros.

Like an if-then, you can write it on one row and separate expressions
with ":".

Best Regards
Eric





All times are GMT +1. The time now is 07:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com