Radio Button Macro

L

Lisa C.

I have two radio buttons labeled "Yes" and "No" within the same group box. I
need a macro to run that hides rows when the "Yes" radio button is chosen and
that unhides rows when the "No" radio button is chosen. What do I need to do
to make the radio buttons automatically run the macro upon clicking them? I
don't know how to tie the macro to the two Yes/No radio buttons or what
syntax to use in the macro to recognize the radio buttons and the result of
Yes or No to make it run. Here is what I have but I'm missing the proper
syntax for the first line.
If [radio button???] = [??] Then
Rows("35:49").Select
Selection.EntireRow.Hidden = True
End If
If [radio button] = [??] Then
Rows("35:49").Select
Selection.EntireRow.Hidden = False
End If
 
D

dhstein

Use these 2 macros instead - then right click on the radio button and "Assign
Macro" to the appropriate one


Sub HideRows()


Rows("35:49").Select
Selection.EntireRow.Hidden = True

End Sub


Sub ShowRows()

Rows("35:49").Select
Selection.EntireRow.Hidden = False

End Sub
 
L

Lisa C.

Wow, that was easy. Thanks!
Is there a way to use a List and run a macro based on the value selected on
the list that hides/unhides worksheets?


dhstein said:
Use these 2 macros instead - then right click on the radio button and "Assign
Macro" to the appropriate one


Sub HideRows()


Rows("35:49").Select
Selection.EntireRow.Hidden = True

End Sub


Sub ShowRows()

Rows("35:49").Select
Selection.EntireRow.Hidden = False

End Sub

Lisa C. said:
I have two radio buttons labeled "Yes" and "No" within the same group box. I
need a macro to run that hides rows when the "Yes" radio button is chosen and
that unhides rows when the "No" radio button is chosen. What do I need to do
to make the radio buttons automatically run the macro upon clicking them? I
don't know how to tie the macro to the two Yes/No radio buttons or what
syntax to use in the macro to recognize the radio buttons and the result of
Yes or No to make it run. Here is what I have but I'm missing the proper
syntax for the first line.
If [radio button???] = [??] Then
Rows("35:49").Select
Selection.EntireRow.Hidden = True
End If
If [radio button] = [??] Then
Rows("35:49").Select
Selection.EntireRow.Hidden = False
End If
 
D

dhstein

I haven't worked with the excel version - but you can create a combo box
which should let you do that. I'll defer to somebody else here that perhaps
can give you more information.

Lisa C. said:
Wow, that was easy. Thanks!
Is there a way to use a List and run a macro based on the value selected on
the list that hides/unhides worksheets?


dhstein said:
Use these 2 macros instead - then right click on the radio button and "Assign
Macro" to the appropriate one


Sub HideRows()


Rows("35:49").Select
Selection.EntireRow.Hidden = True

End Sub


Sub ShowRows()

Rows("35:49").Select
Selection.EntireRow.Hidden = False

End Sub

Lisa C. said:
I have two radio buttons labeled "Yes" and "No" within the same group box. I
need a macro to run that hides rows when the "Yes" radio button is chosen and
that unhides rows when the "No" radio button is chosen. What do I need to do
to make the radio buttons automatically run the macro upon clicking them? I
don't know how to tie the macro to the two Yes/No radio buttons or what
syntax to use in the macro to recognize the radio buttons and the result of
Yes or No to make it run. Here is what I have but I'm missing the proper
syntax for the first line.
If [radio button???] = [??] Then
Rows("35:49").Select
Selection.EntireRow.Hidden = True
End If
If [radio button] = [??] Then
Rows("35:49").Select
Selection.EntireRow.Hidden = False
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top