ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Radio Buttons on Sheets (https://www.excelbanter.com/excel-programming/435693-radio-buttons-sheets.html)

Tim Childs[_2_]

Radio Buttons on Sheets
 
Hi

In a given worksheet with two radio buttons (OptionButton1 and
OptionButton2), what command can show whether the option button has been
selected, please

I tried code like:

If ActiveSheet.OLEObjects("OptionButton1").GotFocus Then MsgBox "test is
true"

but it errored on error 1004 :(

Also, is the selection of the button an "event" and therefore trappable?
i.e. using the code in the sheet module like this:
Private Sub OptionButton1_Click()
MsgBox "test"
End Sub

I could not make that work either, selecting it on the sheet did not seem to
trigger an event.

Any help gratefully received

Tim



JLGWhiz[_2_]

Radio Buttons on Sheets
 
Option buttons have two values. True or False.
Psuedo code example:
If Sheets(1).OpthionButton1.Value = True Then
MsgBox "OB1 is selected"
Else
MsgBox "OB1 is not selected"
End If

"Tim Childs" wrote in message
...
Hi

In a given worksheet with two radio buttons (OptionButton1 and
OptionButton2), what command can show whether the option button has been
selected, please

I tried code like:

If ActiveSheet.OLEObjects("OptionButton1").GotFocus Then MsgBox "test is
true"

but it errored on error 1004 :(

Also, is the selection of the button an "event" and therefore trappable?
i.e. using the code in the sheet module like this:
Private Sub OptionButton1_Click()
MsgBox "test"
End Sub

I could not make that work either, selecting it on the sheet did not seem
to trigger an event.

Any help gratefully received

Tim




JLGWhiz[_2_]

Radio Buttons on Sheets
 
Make sure your buttons are from the Control Toolbox if you want to use the
Click event to initiate the macros.


"Tim Childs" wrote in message
...
Hi

In a given worksheet with two radio buttons (OptionButton1 and
OptionButton2), what command can show whether the option button has been
selected, please

I tried code like:

If ActiveSheet.OLEObjects("OptionButton1").GotFocus Then MsgBox "test is
true"

but it errored on error 1004 :(

Also, is the selection of the button an "event" and therefore trappable?
i.e. using the code in the sheet module like this:
Private Sub OptionButton1_Click()
MsgBox "test"
End Sub

I could not make that work either, selecting it on the sheet did not seem
to trigger an event.

Any help gratefully received

Tim




Tim Childs[_2_]

Radio Buttons on Sheets
 
Hi

many thanks for this - tested and working :)

Tim

"JLGWhiz" wrote in message
...
Option buttons have two values. True or False.
Psuedo code example:
If Sheets(1).OpthionButton1.Value = True Then
MsgBox "OB1 is selected"
Else
MsgBox "OB1 is not selected"
End If

"Tim Childs" wrote in message
...
Hi

In a given worksheet with two radio buttons (OptionButton1 and
OptionButton2), what command can show whether the option button has been
selected, please

I tried code like:

If ActiveSheet.OLEObjects("OptionButton1").GotFocus Then MsgBox "test is
true"

but it errored on error 1004 :(

Also, is the selection of the button an "event" and therefore trappable?
i.e. using the code in the sheet module like this:
Private Sub OptionButton1_Click()
MsgBox "test"
End Sub

I could not make that work either, selecting it on the sheet did not seem
to trigger an event.

Any help gratefully received

Tim






Tim Childs[_2_]

Radio Buttons on Sheets
 
Hi

thanks for that explanation. Have got them working as events.

v grateful

Tim

"JLGWhiz" wrote in message
...
Make sure your buttons are from the Control Toolbox if you want to use the
Click event to initiate the macros.


"Tim Childs" wrote in message
...
Hi

In a given worksheet with two radio buttons (OptionButton1 and
OptionButton2), what command can show whether the option button has been
selected, please

I tried code like:

If ActiveSheet.OLEObjects("OptionButton1").GotFocus Then MsgBox "test is
true"

but it errored on error 1004 :(

Also, is the selection of the button an "event" and therefore trappable?
i.e. using the code in the sheet module like this:
Private Sub OptionButton1_Click()
MsgBox "test"
End Sub

I could not make that work either, selecting it on the sheet did not seem
to trigger an event.

Any help gratefully received

Tim







All times are GMT +1. The time now is 10:09 AM.

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