ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   option button help please (https://www.excelbanter.com/excel-programming/343283-option-button-help-please.html)

Gary Keramidas

option button help please
 
see if i can explain what i want to accomplish:

i have data validation dropdowns in a2 and a3, starting month to ending
month, to run a report

i have 3 option buttons, depending on the report to run

i was wondering if there was a way to run whatever optionbutton code that
was last selected
when the value in a3 changes.

right now, when i change the month in a3 and i want to run the report i just
ran with different dates, i have to click one of the other option buttons
and
then come back and click the option button i want.

i thought a worksheet change will do, and i can check to see what option
button was last selected, but i don't know how to run its associated
code..
--


Gary





George Nicholson[_2_]

option button help please
 
but i don't know how to run its associated code...

If it's a worksheet control, run whatever macro you assigned to it.

If it's a Forms/VB control, simply call it's Click event as you would any
other sub or function:
OptionButton1_Click
or
Call OptionButton1_Click
where OptionButton1 is the name of the control.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
see if i can explain what i want to accomplish:

i have data validation dropdowns in a2 and a3, starting month to ending
month, to run a report

i have 3 option buttons, depending on the report to run

i was wondering if there was a way to run whatever optionbutton code that
was last selected
when the value in a3 changes.

right now, when i change the month in a3 and i want to run the report i
just
ran with different dates, i have to click one of the other option buttons
and
then come back and click the option button i want.

i thought a worksheet change will do, and i can check to see what option
button was last selected, but i don't know how to run its associated
code..
--


Gary







Gary Keramidas

option button help please
 
thanks, george, the optionbutton_click is what i needed. does this look ok?

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count = 1 Then
If Not Intersect(Target, Range("A3")) Is Nothing Then
If Worksheets("report").OptionButton1 = True Then
OptionButton1_Click
ElseIf Worksheets("report").OptionButton2 = True Then
OptionButton2_Click
Else
OptionButton3_Click
End If
End If
End If
End Sub

--


Gary


"George Nicholson" wrote in message
...
but i don't know how to run its associated code...


If it's a worksheet control, run whatever macro you assigned to it.

If it's a Forms/VB control, simply call it's Click event as you would any
other sub or function:
OptionButton1_Click
or
Call OptionButton1_Click
where OptionButton1 is the name of the control.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
see if i can explain what i want to accomplish:

i have data validation dropdowns in a2 and a3, starting month to ending
month, to run a report

i have 3 option buttons, depending on the report to run

i was wondering if there was a way to run whatever optionbutton code that
was last selected
when the value in a3 changes.

right now, when i change the month in a3 and i want to run the report i
just
ran with different dates, i have to click one of the other option buttons
and
then come back and click the option button i want.

i thought a worksheet change will do, and i can check to see what option
button was last selected, but i don't know how to run its associated
code..
--


Gary










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

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