[vba] Onclick property triggering ?

M

marc

Hello,

I wish to change a command button's vba script
according to different values (so it is dynamic)

For example :

if A=4 then the script attached to
the command button is "here the first vba script"

if A=61 then the script attached to
the command button is "here the SEcond- vba script"


Does Onclick property will do it ?
How can i write it with the proper syntaxe ?


Thank you
 
W

Wayne Morgan

In the OnClick event, something like this will do what you are asking.

Select Case A
Case 4
MsgBox "Here is the first VBA script."
Case 61
MsgBox "Here is the second VBA script."
Case Else
MsgBox "Bad value for A."
End Select
 
T

Tim Miller

Is it too much that you can't include it all in one script with the criteria
(if then) giving direction to the script?
The I would think (perhasp there are better ways) the onClick script would
be If Then that called up separate modules depending on the results. Then
you'd put your different scripts in the different modules.
I would think that's what you'd do. I'm sure you can't actually change the
script depending on the circumstance. You can just include all possible
circumstances along with direction.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top