Fordraiders
asked on
Deselect all optionbuttons on userform to 0
excel 2010
Userform
Multipage1 control
Page 5
The following code will deselect all the optionbuttons on all pages.
ans also code not owrking just for Page5?
I need just specifically for page 5
' this works but does all the optionbuttons on any page
Dim cCont As Control
For Each cCont In Me.Controls
If TypeName(cCont) = "OptionButton" Then
cCont.Value = False
End If
Next cCont
' specficially for page 5 but getting error
Dim pg As Pages
Dim ctl As MSForms.Control
Dim OptChecked As String
Set pg = Me.MultiPage1.Pages(5) ' pages are 0 indexed <--- error here "type mismatch
For Each ctl In pg.Controls
If TypeName(ctl) = "OptionButton" Then
ctl.Value = 0
End If
Next ctl
Thanks
fordraiders
Userform
Multipage1 control
Page 5
The following code will deselect all the optionbuttons on all pages.
ans also code not owrking just for Page5?
I need just specifically for page 5
' this works but does all the optionbuttons on any page
Dim cCont As Control
For Each cCont In Me.Controls
If TypeName(cCont) = "OptionButton" Then
cCont.Value = False
End If
Next cCont
' specficially for page 5 but getting error
Dim pg As Pages
Dim ctl As MSForms.Control
Dim OptChecked As String
Set pg = Me.MultiPage1.Pages(5) ' pages are 0 indexed <--- error here "type mismatch
For Each ctl In pg.Controls
If TypeName(ctl) = "OptionButton" Then
ctl.Value = 0
End If
Next ctl
Thanks
fordraiders
ASKER
Still type mismatch on line below
Dim pg As Page
Dim ctl As MSForms.Control
Dim OptChecked As String
Set pg = Me.MultiPage1.Pages(4) <----- Still Type mistmatch on this line
For Each ctl In pg.Controls
If TypeName(ctl) = "OptionButton" Then
ctl.Value = 0
End If
Next ctl
Dim pg As Page
Dim ctl As MSForms.Control
Dim OptChecked As String
Set pg = Me.MultiPage1.Pages(4) <----- Still Type mistmatch on this line
For Each ctl In pg.Controls
If TypeName(ctl) = "OptionButton" Then
ctl.Value = 0
End If
Next ctl
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok great Thanks
Dim pg As MSForms.Page
Dim ctl As MSForms.Control
Set pg = Me.MultiPage1.Pages(4)
For Each ctl In pg.Controls
If TypeName(ctl) = "OptionButton" Then
ctl.Value = 0
End If
Next ctl
also got this to work...
Dim cCnt As Control
For Each cCnt In Me.MultiPage1.Pages(4).Con trols
If TypeName(cCnt) = "OptionButton" Then
cCnt.Value = 0
End If
Next cCnt
Dim pg As MSForms.Page
Dim ctl As MSForms.Control
Set pg = Me.MultiPage1.Pages(4)
For Each ctl In pg.Controls
If TypeName(ctl) = "OptionButton" Then
ctl.Value = 0
End If
Next ctl
also got this to work...
Dim cCnt As Control
For Each cCnt In Me.MultiPage1.Pages(4).Con
If TypeName(cCnt) = "OptionButton" Then
cCnt.Value = 0
End If
Next cCnt
ASKER
Thanks very much !
Dim ctl As MSForms.Control
Dim OptChecked As String
Set pg = Me.MultiPage1.Pages(4)
note the bold parts. ;)