Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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





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
Select sheets ina workbook based on radio buttons and move them Larry Fitch Excel Worksheet Functions 4 September 28th 09 01:42 AM
Use of Radio Buttons DR Excel Discussion (Misc queries) 4 August 19th 08 07:51 PM
Option Buttons/Radio Buttons John Calder New Users to Excel 7 May 16th 08 03:51 AM
Radio Buttons Bethie at CLG Excel Worksheet Functions 6 October 31st 05 09:08 PM
VBA: Disable Frame and Radio Buttons based on Another Radio Button Being True Mcasteel Excel Worksheet Functions 2 October 29th 04 07:06 PM


All times are GMT +1. The time now is 08:52 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"