#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default parameter

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default parameter

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default parameter

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
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 to choose if I use a parameter or not in a parameter query Arnaud Excel Discussion (Misc queries) 0 March 8th 07 01:19 PM
What does this parameter mean? ManKind Excel Programming 1 June 5th 06 06:05 AM
The parameter is incorrect overcanyon[_2_] Excel Programming 7 January 31st 06 06:53 PM
What does the second parameter in ACCRINT do? Boris Excel Worksheet Functions 0 January 6th 06 01:08 AM
parameter value query Brad Vontur[_2_] Excel Programming 0 April 6th 04 04:46 PM


All times are GMT +1. The time now is 03:56 PM.

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

About Us

"It's about Microsoft Excel"