ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UserForms: Clear all Option Buttons (https://www.excelbanter.com/excel-programming/389688-userforms-clear-all-option-buttons.html)

Shawn

UserForms: Clear all Option Buttons
 
I have a file that uses several userforms. These userforms have several
option buttons and check boxes on each.


During "UserForm_Activate()" what code will clear all option buttons and
check boxes at once?

--
Thanks
Shawn

Shawn

UserForms: Clear all Option Buttons
 
This won't work?

Sub ClearOptButChBx()

Dim usf As UserForm
Dim OLEObj As OLEObject

Set usf = ActiveUserForm

For Each OLEObj In usf.OLEObjects
If TypeOf OLEObj.Object Is MSForms.CheckBox Or TypeOf OLEObj.Object
Is MSForms.OptionButton Then
OLEObj.Object.Value = False
End If
Next OLEObj

End Sub


--
Thanks
Shawn


"Shawn" wrote:

I have a file that uses several userforms. These userforms have several
option buttons and check boxes on each.


During "UserForm_Activate()" what code will clear all option buttons and
check boxes at once?

--
Thanks
Shawn


Shawn

UserForms: Clear all Option Buttons
 
Instead of setting the userform to "hide" I "unload" it. That seems to do
the trick.
--
Thanks
Shawn


"Shawn" wrote:

This won't work?

Sub ClearOptButChBx()

Dim usf As UserForm
Dim OLEObj As OLEObject

Set usf = ActiveUserForm

For Each OLEObj In usf.OLEObjects
If TypeOf OLEObj.Object Is MSForms.CheckBox Or TypeOf OLEObj.Object
Is MSForms.OptionButton Then
OLEObj.Object.Value = False
End If
Next OLEObj

End Sub


--
Thanks
Shawn


"Shawn" wrote:

I have a file that uses several userforms. These userforms have several
option buttons and check boxes on each.


During "UserForm_Activate()" what code will clear all option buttons and
check boxes at once?

--
Thanks
Shawn



All times are GMT +1. The time now is 06:25 PM.

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