Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a Userform.
the userform have 9 button. cmdBtn1, cmdBtn2, .... cmdBtn9 that buttons have a procedure respectively. I want to run the button procedure using loop. for example, for i=1 to 9 application.run "cmdBtn" & i next but debug.... How can I..... *** Sent via Developersdex http://www.developersdex.com *** |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you are going to run nine procedures consecutively, then why not take them
out of the controls, rename them and put them in a module. Then you can create a master procedure that calls the nine, as in the example below: Sub master() macro1 macro2 ... macro9 End Sub Or, if you need to use a command button, then call them all from one button's click event in a similar manner as the example above. "x taol" wrote: I have a Userform. the userform have 9 button. cmdBtn1, cmdBtn2, .... cmdBtn9 that buttons have a procedure respectively. I want to run the button procedure using loop. for example, for i=1 to 9 application.run "cmdBtn" & i next but debug.... How can I..... *** Sent via Developersdex http://www.developersdex.com *** |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What you can do is shift the code for each button to a module and then call
the sub in the module when the individual button is clicked. Examples:- Private Sub cmdBtn1_Click() Call modCmdBtn1 End Sub Private Sub cmdBtn2_Click() Call modCmdBtn2 End Sub In the module you then set your subs up as per this example:- Sub modCmdBtn1() MsgBox "This is modCmdBtn1()" 'Used this for testing End Sub Sub modCmdBtn2() MsgBox "This is modCmdBtn2()" End Sub The following if attached to a button will call each of the subs in the module using the For/Next routine. Private Sub RunCode_Click() For i = 1 To 9 strSubName = "modCmdBtn" & i Application.Run (strSubName) Next i End Sub -- Regards, OssieMac "JLGWhiz" wrote: If you are going to run nine procedures consecutively, then why not take them out of the controls, rename them and put them in a module. Then you can create a master procedure that calls the nine, as in the example below: Sub master() macro1 macro2 ... macro9 End Sub Or, if you need to use a command button, then call them all from one button's click event in a similar manner as the example above. "x taol" wrote: I have a Userform. the userform have 9 button. cmdBtn1, cmdBtn2, .... cmdBtn9 that buttons have a procedure respectively. I want to run the button procedure using loop. for example, for i=1 to 9 application.run "cmdBtn" & i next but debug.... How can I..... *** Sent via Developersdex http://www.developersdex.com *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to choose if I use a parameter or not in a parameter query | Excel Discussion (Misc queries) | |||
What does this parameter mean? | Excel Programming | |||
The parameter is incorrect | Excel Programming | |||
What does the second parameter in ACCRINT do? | Excel Worksheet Functions | |||
parameter value query | Excel Programming |