ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can I reset an Excel form that has radio buttons. (https://www.excelbanter.com/excel-programming/360468-how-can-i-reset-excel-form-has-radio-buttons.html)

JaxPM

How can I reset an Excel form that has radio buttons.
 
using version 2003.

Tom Ogilvy

How can I reset an Excel form that has radio buttons.
 
Dim ctrl as Control
for each ctrl in Userform1.Controls
if typeof ctrl is MSforms.OptionButton then
ctrl.Value = False
end if
Next

--
Regards,
Tom Ogilvy


"JaxPM" wrote:

using version 2003.


JaxPM

How can I reset an Excel form that has radio buttons.
 
I'm a newbie. I tried pasting the macro 'as is' and assigning a button. It
didn't work. What am I doing wrong?

"Tom Ogilvy" wrote:

Dim ctrl as Control
for each ctrl in Userform1.Controls
if typeof ctrl is MSforms.OptionButton then
ctrl.Value = False
end if
Next

--
Regards,
Tom Ogilvy


"JaxPM" wrote:

using version 2003.


Tom Ogilvy

How can I reset an Excel form that has radio buttons.
 
I had a userform with three optionbuttons. I place a commandbutton on the
sheet (commandbutton2). I then double clicked on the command button (in the
vbe in design mode) and it took me to

Private Sub CommandButton2_click()

End sub

I then altered that code to:

Private Sub CommandButton2_Click()
Dim ctrl As Control
For Each ctrl In UserForm1.Controls
If TypeOf ctrl Is MSforms.OptionButton Then
ctrl.Value = False
End If
Next

End Sub

then I showed the userform and clicked one of the optionbuttons. I clicked
commandbutton2 and the optionbuttons were all unselected.

--
Regards,
Tom Ogilvy


"JaxPM" wrote:

I'm a newbie. I tried pasting the macro 'as is' and assigning a button. It
didn't work. What am I doing wrong?

"Tom Ogilvy" wrote:

Dim ctrl as Control
for each ctrl in Userform1.Controls
if typeof ctrl is MSforms.OptionButton then
ctrl.Value = False
end if
Next

--
Regards,
Tom Ogilvy


"JaxPM" wrote:

using version 2003.


JaxPM

How can I reset an Excel form that has radio buttons.
 
I get this error msg:
"User-defined type not defined"

"Tom Ogilvy" wrote:

I had a userform with three optionbuttons. I place a commandbutton on the
sheet (commandbutton2). I then double clicked on the command button (in the
vbe in design mode) and it took me to

Private Sub CommandButton2_click()

End sub

I then altered that code to:

Private Sub CommandButton2_Click()
Dim ctrl As Control
For Each ctrl In UserForm1.Controls
If TypeOf ctrl Is MSforms.OptionButton Then
ctrl.Value = False
End If
Next

End Sub

then I showed the userform and clicked one of the optionbuttons. I clicked
commandbutton2 and the optionbuttons were all unselected.

--
Regards,
Tom Ogilvy


"JaxPM" wrote:

I'm a newbie. I tried pasting the macro 'as is' and assigning a button. It
didn't work. What am I doing wrong?

"Tom Ogilvy" wrote:

Dim ctrl as Control
for each ctrl in Userform1.Controls
if typeof ctrl is MSforms.OptionButton then
ctrl.Value = False
end if
Next

--
Regards,
Tom Ogilvy


"JaxPM" wrote:

using version 2003.


Tom Ogilvy

How can I reset an Excel form that has radio buttons.
 
I had a userform with three optionbuttons. I place a commandbutton on the
sheet (commandbutton2). I then double clicked on the command button (in the
vbe in design mode) and it took me to

Private Sub CommandButton2_click()

End sub

I then altered that code to:

Private Sub CommandButton2_Click()
Dim ctrl As Control
For Each ctrl In UserForm1.Controls
If TypeOf ctrl Is MSforms.OptionButton Then
ctrl.Value = False
End If
Next

End Sub

then I showed the userform and clicked one of the optionbuttons. I clicked
commandbutton2 and the optionbuttons were all unselected.

--
Regards,
Tom Ogilvy

"JaxPM" wrote in message
...
I get this error msg:
"User-defined type not defined"

"Tom Ogilvy" wrote:

I had a userform with three optionbuttons. I place a commandbutton on

the
sheet (commandbutton2). I then double clicked on the command button (in

the
vbe in design mode) and it took me to

Private Sub CommandButton2_click()

End sub

I then altered that code to:

Private Sub CommandButton2_Click()
Dim ctrl As Control
For Each ctrl In UserForm1.Controls
If TypeOf ctrl Is MSforms.OptionButton Then
ctrl.Value = False
End If
Next

End Sub

then I showed the userform and clicked one of the optionbuttons. I

clicked
commandbutton2 and the optionbuttons were all unselected.

--
Regards,
Tom Ogilvy


"JaxPM" wrote:

I'm a newbie. I tried pasting the macro 'as is' and assigning a

button. It
didn't work. What am I doing wrong?

"Tom Ogilvy" wrote:

Dim ctrl as Control
for each ctrl in Userform1.Controls
if typeof ctrl is MSforms.OptionButton then
ctrl.Value = False
end if
Next

--
Regards,
Tom Ogilvy


"JaxPM" wrote:

using version 2003.





All times are GMT +1. The time now is 01:43 AM.

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