ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Changing radio button control (https://www.excelbanter.com/excel-programming/385665-changing-radio-button-control.html)

Andreww

Changing radio button control
 
Hi - I have two radio buttons the code for which sits in the sheets
"code area" (as opposed to module'n'. The two buttons are linked such
that only one can be "filled in",

I am trying to trap an error that occurs later on when one of the
radio buttons is clicked and under certain conditions. Rather than
the 2nd radio button being "filled in" I wan the existing button keeps
it's "filled in" value.

I have created code which changes the values of the buttons to what I
want them to be when the error occurs.

My problem is that as the code is on the worksheet code area, I can't
see how the code can be called from my module1 procedure???

The code is:

'1st button is clicked and it does.. things
Private Sub OptionButton1_Click()
'Sheets("admin").Select
Range("A1").Value = 1
'Sheets("Detail").Select

' Module 1 code that does a pile of things
Call make_formula
End Sub

' Changes values of buttons
Sub reset_buttons_on_error()
OptionButton2.Value = False
OptionButton1.Value = True
End Sub

'What happens when 2nd button is clicked
Private Sub OptionButton2_Click()
'Sheets("admin").Select
Range("A1").Value = 2
'Sheets("Detail").Select
Call make_formula
End Sub

I am sure this is basic stuff but I can't see how to do it.

Thanks

Andrew


merjet

Changing radio button control
 
My problem is that as the code is on the worksheet code area, I can't
see how the code can be called from my module1 procedure???


Do you mean reset_buttons_on_error()?

If yes, qualify like this:

Sheets("Sheet1").reset_buttons_on_error

Hth,
Merjet




Andreww

Changing radio button control
 
Thanks Merjet.

Works great.

Andrew



All times are GMT +1. The time now is 06:42 PM.

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