[vba] Onclick property triggering ?

  • Thread starter Thread starter marc
  • Start date Start date
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
 
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
 
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.
 
Back
Top