ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   reset control toolbox optionbuttons (https://www.excelbanter.com/excel-programming/375813-reset-control-toolbox-optionbuttons.html)

[email protected]

reset control toolbox optionbuttons
 
Hi,

I want to reset all (control toolbox-)optionbuttons on an excel-
worksheet.
I've already came to this, but now I'm stuck:

Dim obj As OLEObject
Dim cnt As Long
'cnt = 0
For Each obj In ActiveSheet.OLEObjects
If TypeOf obj.Object Is MSForms.OptionButton Then
'cnt = cnt + 1
' HERE I HAVE TO SET THE VALUE TO FALSE <<<
End If
Next
'MsgBox "Number of optionbuttons is " & cnt

Am I doing this right so far, or do I have to follow another approach?
I really need this as quick as possible...
thx...


Bob Phillips

reset control toolbox optionbuttons
 
I take it this is what you want

Dim obj As OLEObject
Dim cnt As Long
For Each obj In ActiveSheet.OLEObjects
If TypeOf obj.Object Is MSForms.OptionButton Then
cnt = cnt + 1
obj.Object.Value = False
End If
Next
MsgBox "Number of optionbuttons is " & cnt

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
oups.com...
Hi,

I want to reset all (control toolbox-)optionbuttons on an excel-
worksheet.
I've already came to this, but now I'm stuck:

Dim obj As OLEObject
Dim cnt As Long
'cnt = 0
For Each obj In ActiveSheet.OLEObjects
If TypeOf obj.Object Is MSForms.OptionButton Then
'cnt = cnt + 1
' HERE I HAVE TO SET THE VALUE TO FALSE <<<
End If
Next
'MsgBox "Number of optionbuttons is " & cnt

Am I doing this right so far, or do I have to follow another approach?
I really need this as quick as possible...
thx...




[email protected]

reset control toolbox optionbuttons
 
Thank you so much Bob!



All times are GMT +1. The time now is 11:50 PM.

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