Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Check if a optionbutton is selected

Hi,

In a userform I use three optionbuttons. One of them must be selected by the
user. How can let VBA check if this is done?

Regards, Gert-Jan


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Check if a optionbutton is selected

Hi Martin,

Thanks, but I know what I have to do. Isn't there a way to do this simple
and fast (not depending on the number of optionbuttons)?

Gert-Jan

"Martin Fishlock" schreef in bericht
...
Hi,

You need to check each of the buttons for true.

Another way is to seta default for button1 to true in the form design (or
at
initialization).

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Gert-Jan" wrote:

Hi,

In a userform I use three optionbuttons. One of them must be selected by
the
user. How can let VBA check if this is done?

Regards, Gert-Jan





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Check if a optionbutton is selected

maybe something like this, change userform1 to your userform name

Dim optionbuttom As Control
For Each OptionButton In UserForm1.Controls
If OptionButton.Value = True Then
MsgBox OptionButton.Caption & " = True"
End If
Next

--


Gary


"Gert-Jan" wrote in message
.. .
Hi Martin,

Thanks, but I know what I have to do. Isn't there a way to do this simple and
fast (not depending on the number of optionbuttons)?

Gert-Jan

"Martin Fishlock" schreef in bericht
...
Hi,

You need to check each of the buttons for true.

Another way is to seta default for button1 to true in the form design (or at
initialization).

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Gert-Jan" wrote:

Hi,

In a userform I use three optionbuttons. One of them must be selected by the
user. How can let VBA check if this is done?

Regards, Gert-Jan







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Check if a optionbutton is selected

sorry, there is a typo in the first line:
Dim Optionbutton As Control


--


Gary


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
maybe something like this, change userform1 to your userform name

Dim optionbuttom As Control
For Each OptionButton In UserForm1.Controls
If OptionButton.Value = True Then
MsgBox OptionButton.Caption & " = True"
End If
Next

--


Gary


"Gert-Jan" wrote in message
.. .
Hi Martin,

Thanks, but I know what I have to do. Isn't there a way to do this simple and
fast (not depending on the number of optionbuttons)?

Gert-Jan

"Martin Fishlock" schreef in bericht
...
Hi,

You need to check each of the buttons for true.

Another way is to seta default for button1 to true in the form design (or at
initialization).

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Gert-Jan" wrote:

Hi,

In a userform I use three optionbuttons. One of them must be selected by
the
user. How can let VBA check if this is done?

Regards, Gert-Jan









  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Check if a optionbutton is selected

I don't believe that the group or frame properties allow for the
identificaiton of the option button that is true.

The solution is to write a generic function that returns the name to the
optionbutton that is true in a group.

Not much help.
--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Gert-Jan" wrote:

Hi Martin,

Thanks, but I know what I have to do. Isn't there a way to do this simple
and fast (not depending on the number of optionbuttons)?

Gert-Jan

"Martin Fishlock" schreef in bericht
...
Hi,

You need to check each of the buttons for true.

Another way is to seta default for button1 to true in the form design (or
at
initialization).

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Gert-Jan" wrote:

Hi,

In a userform I use three optionbuttons. One of them must be selected by
the
user. How can let VBA check if this is done?

Regards, Gert-Jan








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Check if a optionbutton is selected

I see what you want to do, but this is not what I want (and it also doesn't
work). In my userform I have three option buttons. Final operation: check if
one of the optionbuttons is clicked. If not: msgbox "please select an option
first"

Gert-Jan

"Gary Keramidas" <GKeramidasATmsn.com schreef in bericht
...
maybe something like this, change userform1 to your userform name

Dim optionbuttom As Control
For Each OptionButton In UserForm1.Controls
If OptionButton.Value = True Then
MsgBox OptionButton.Caption & " = True"
End If
Next

--


Gary


"Gert-Jan" wrote in message
.. .
Hi Martin,

Thanks, but I know what I have to do. Isn't there a way to do this simple
and fast (not depending on the number of optionbuttons)?

Gert-Jan

"Martin Fishlock" schreef in
bericht ...
Hi,

You need to check each of the buttons for true.

Another way is to seta default for button1 to true in the form design
(or at
initialization).

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Gert-Jan" wrote:

Hi,

In a userform I use three optionbuttons. One of them must be selected
by the
user. How can let VBA check if this is done?

Regards, Gert-Jan









  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Check if a optionbutton is selected

if you only have 3 option buttons:

If Me.OptionButton1.Value = False And Me.OptionButton2.Value = False And _
Me.OptionButton3.Value = False Then MsgBox " you must select an option
button"


--


Gary


"Gert-Jan" wrote in message
.. .
I see what you want to do, but this is not what I want (and it also doesn't
work). In my userform I have three option buttons. Final operation: check if
one of the optionbuttons is clicked. If not: msgbox "please select an option
first"

Gert-Jan

"Gary Keramidas" <GKeramidasATmsn.com schreef in bericht
...
maybe something like this, change userform1 to your userform name

Dim optionbuttom As Control
For Each OptionButton In UserForm1.Controls
If OptionButton.Value = True Then
MsgBox OptionButton.Caption & " = True"
End If
Next

--


Gary


"Gert-Jan" wrote in message
.. .
Hi Martin,

Thanks, but I know what I have to do. Isn't there a way to do this simple
and fast (not depending on the number of optionbuttons)?

Gert-Jan

"Martin Fishlock" schreef in bericht
...
Hi,

You need to check each of the buttons for true.

Another way is to seta default for button1 to true in the form design (or
at
initialization).

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Gert-Jan" wrote:

Hi,

In a userform I use three optionbuttons. One of them must be selected by
the
user. How can let VBA check if this is done?

Regards, Gert-Jan











  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Check if a optionbutton is selected

if OptionButton1.Value or OptionButton2.Value or _
OptionButton3.Value then
' one button is selected
else
msgbox "please select an option first"
end if


--
Regards
Tom Ogilvy

"Gert-Jan" wrote in message
.. .
I see what you want to do, but this is not what I want (and it also doesn't
work). In my userform I have three option buttons. Final operation: check
if one of the optionbuttons is clicked. If not: msgbox "please select an
option first"

Gert-Jan

"Gary Keramidas" <GKeramidasATmsn.com schreef in bericht
...
maybe something like this, change userform1 to your userform name

Dim optionbuttom As Control
For Each OptionButton In UserForm1.Controls
If OptionButton.Value = True Then
MsgBox OptionButton.Caption & " = True"
End If
Next

--


Gary


"Gert-Jan" wrote in message
.. .
Hi Martin,

Thanks, but I know what I have to do. Isn't there a way to do this
simple and fast (not depending on the number of optionbuttons)?

Gert-Jan

"Martin Fishlock" schreef in
bericht ...
Hi,

You need to check each of the buttons for true.

Another way is to seta default for button1 to true in the form design
(or at
initialization).

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Gert-Jan" wrote:

Hi,

In a userform I use three optionbuttons. One of them must be selected
by the
user. How can let VBA check if this is done?

Regards, Gert-Jan











  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Check if a optionbutton is selected

Thanks, this works fine for this moment.

Gert-Jan

"Gary Keramidas" <GKeramidasATmsn.com schreef in bericht
...
if you only have 3 option buttons:

If Me.OptionButton1.Value = False And Me.OptionButton2.Value = False And _
Me.OptionButton3.Value = False Then MsgBox " you must select an option
button"


--


Gary


"Gert-Jan" wrote in message
.. .
I see what you want to do, but this is not what I want (and it also
doesn't work). In my userform I have three option buttons. Final
operation: check if one of the optionbuttons is clicked. If not: msgbox
"please select an option first"

Gert-Jan

"Gary Keramidas" <GKeramidasATmsn.com schreef in bericht
...
maybe something like this, change userform1 to your userform name

Dim optionbuttom As Control
For Each OptionButton In UserForm1.Controls
If OptionButton.Value = True Then
MsgBox OptionButton.Caption & " = True"
End If
Next

--


Gary


"Gert-Jan" wrote in message
.. .
Hi Martin,

Thanks, but I know what I have to do. Isn't there a way to do this
simple and fast (not depending on the number of optionbuttons)?

Gert-Jan

"Martin Fishlock" schreef in
bericht ...
Hi,

You need to check each of the buttons for true.

Another way is to seta default for button1 to true in the form design
(or at
initialization).

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Gert-Jan" wrote:

Hi,

In a userform I use three optionbuttons. One of them must be selected
by the
user. How can let VBA check if this is done?

Regards, Gert-Jan













  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Check if a optionbutton is selected

or how about something like this? just add your code instead of the message
boxes

Private Sub CommandButton1_Click()
Select Case True
Case Me.OptionButton1
MsgBox "optionbutton1 selected"
Case Me.OptionButton2
MsgBox "optionbutton2 selected"
Case Me.OptionButton3
MsgBox "optionbutton3 selected"
Case Else
MsgBox "no optionbutton selected"
End Select
End Sub



--


Gary


"Gert-Jan" wrote in message
.. .
Thanks, this works fine for this moment.

Gert-Jan

"Gary Keramidas" <GKeramidasATmsn.com schreef in bericht
...
if you only have 3 option buttons:

If Me.OptionButton1.Value = False And Me.OptionButton2.Value = False And _
Me.OptionButton3.Value = False Then MsgBox " you must select an option
button"


--


Gary


"Gert-Jan" wrote in message
.. .
I see what you want to do, but this is not what I want (and it also doesn't
work). In my userform I have three option buttons. Final operation: check if
one of the optionbuttons is clicked. If not: msgbox "please select an option
first"

Gert-Jan

"Gary Keramidas" <GKeramidasATmsn.com schreef in bericht
...
maybe something like this, change userform1 to your userform name

Dim optionbuttom As Control
For Each OptionButton In UserForm1.Controls
If OptionButton.Value = True Then
MsgBox OptionButton.Caption & " = True"
End If
Next

--


Gary


"Gert-Jan" wrote in message
.. .
Hi Martin,

Thanks, but I know what I have to do. Isn't there a way to do this simple
and fast (not depending on the number of optionbuttons)?

Gert-Jan

"Martin Fishlock" schreef in bericht
...
Hi,

You need to check each of the buttons for true.

Another way is to seta default for button1 to true in the form design (or
at
initialization).

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Gert-Jan" wrote:

Hi,

In a userform I use three optionbuttons. One of them must be selected by
the
user. How can let VBA check if this is done?

Regards, Gert-Jan















Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA how to check if entire row is selected? Jack Sons Excel Discussion (Misc queries) 6 April 23rd 23 09:00 PM
How do I check the number of rows selected [email protected] Excel Programming 4 August 8th 06 01:27 PM
OptionButton Check Information Hog[_7_] Excel Programming 0 August 23rd 05 05:53 PM
How do I print hyperlinked files when selected from a check box? Tracy at CNC Excel Programming 0 December 9th 04 02:13 PM
check for selected columns in a macro philip watson Excel Programming 1 December 2nd 03 09:48 PM


All times are GMT +1. The time now is 10:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"