VBA shortcut

T

Thrava

Hi folks,

How can I shortent this code?

i have an event procedure that triggers about 10
optionboxes to become disabled.

So if a click event occurs, then the following happens.

optionbox1.enabled=false
optionbox2.enabled=false
etc..

How can I write one statement... such as..
dim n as integer
for n=1 to 10
do
optionbox(n).enabled=false

or something like this.
is it possible?
Thanks
Trava
 
B

Bob Phillips

Hi Thrava,

If it is Forms buttons on a worksheet use

activesheet.optionbuttons.enabled=false


If it is control tolbox buttons, use

Dim oOLE As OLEObject

For Each oOLE In ActiveSheet.OLEObjects
If TypeOf oOLE.Object Is MSForms.OptionButton Then
oOLE.Enabled = False
End If
Next oOLE


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
T

Thrava

Hello Bob,
Thank you.
I only want to control a subset of the option buttons.
there are other objects on the sheet, such as combobox
etc.. as well.

How do I control only some of them with this sub that you
suggested?
Thanks
Thrava
 
Top