ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Initialize Option Buttons (https://www.excelbanter.com/excel-programming/328950-initialize-option-buttons.html)

Jeff Wright[_2_]

Initialize Option Buttons
 
Greetings, all

I have 82 option buttons, and I want to write a routine which will set the
value of all even-numbered option button numbers to TRUE. I tried:

For i = 1 to 82 Step 2
Sheets("Data").OptionButton(i) = true
Next i

Not too surprisingly, this didn't work. I can write lines and lines of code
to accomplish this, but am looking for a more efficient method. Any ideas?

Thanks,

Jeff



Tom Ogilvy

Initialize Option Buttons
 
For i = 2 to 82 Step 2
Sheets("Data").OleObjects("OptionButton" _
& i).Object.value = true
Next i

This assumes each of the optionbuttons that are being changed are in
separate groups. If they are all in the same group, then you can only set
one to true.

--
Regards,
Tom Ogilvy

"Jeff Wright" wrote in message
news:VLbfe.13238$tQ.5676@fed1read06...
Greetings, all

I have 82 option buttons, and I want to write a routine which will set the
value of all even-numbered option button numbers to TRUE. I tried:

For i = 1 to 82 Step 2
Sheets("Data").OptionButton(i) = true
Next i

Not too surprisingly, this didn't work. I can write lines and lines of

code
to accomplish this, but am looking for a more efficient method. Any ideas?

Thanks,

Jeff





Jeff Wright[_2_]

Initialize Option Buttons
 
Thanks Tom! This does the trick.

Jeff

"Tom Ogilvy" wrote in message
...
For i = 2 to 82 Step 2
Sheets("Data").OleObjects("OptionButton" _
& i).Object.value = true
Next i

This assumes each of the optionbuttons that are being changed are in
separate groups. If they are all in the same group, then you can only set
one to true.

--
Regards,
Tom Ogilvy

"Jeff Wright" wrote in message
news:VLbfe.13238$tQ.5676@fed1read06...
Greetings, all

I have 82 option buttons, and I want to write a routine which will set
the
value of all even-numbered option button numbers to TRUE. I tried:

For i = 1 to 82 Step 2
Sheets("Data").OptionButton(i) = true
Next i

Not too surprisingly, this didn't work. I can write lines and lines of

code
to accomplish this, but am looking for a more efficient method. Any
ideas?

Thanks,

Jeff








All times are GMT +1. The time now is 07:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com