Name OptionButtons from Sheet

R

RobC

Need some help... I have a form with 20 OptionButtons and want to update
the Captions during initialization from a list on a worksheet. Simple
concatenating "OptionButton & x" does not seem to work to step through a
list. Thanks in advance. RobC
 
D

Dave Peterson

I'm not sure how you associate the captions with the list, but maybe this'll
help:

Option Explicit
Sub testme()
Dim iCtr As Long
For iCtr = 1 To 20
Worksheets("sheet1").OLEObjects("Optionbutton" & iCtr).Object.Caption _
= "Hi There " & iCtr
Next iCtr
End Sub
 
R

RobC

Dave,

Thanks that works great for OptionButtons on a Worksheet but mine are on a
Form. I can't seem to get the - "Optionbutton" & iCtr - to work on a Form.
The Cancatenate of the "OptionButton" & x just doesn't work. I tried to
replace the Worksheets("Sheet1") with the Form Name but no go.
 
R

RobC

Dave,

Figured it out...

Form1.Controls.Item("OptionButton" & iCtr).Caption = "www " & iCtr

You got me in the right direction,

Thanks, Rob
 
D

Dave Peterson

Glad you found the solution.
Dave,

Figured it out...

Form1.Controls.Item("OptionButton" & iCtr).Caption = "www " & iCtr

You got me in the right direction,

Thanks, Rob
 

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