A
AG
[XL2002 and soon XL2003 on Win2000SP2]
I require some assistance with a macro I have attempted to write to
unhide certain rows when one of three option buttons (OB) is selected.
Where I am running into problems is trying to logically determine the
code necessary to add when I have added additional groups of OB as well
as what happens/needs to happen once the rows are unhidden.
Specifically, my form is comprised of 2 sections; the 1st section is
composed of 6 groups of 3 option buttons (each group of OB corresponds
to one column of data (choices are Canada/US/Other). When a user selects
the Other option, a range of rows is unhidden underneath the 1st section
the for the user to key foreign exchange rates (note that once the user
has at least one Other OB selected, the same rows will apply to all 6
columns). The 2nd section is just a duplicate of the first allowing the
user a total of 12 possible items to key. All groups are functioning
independently and working well. My macro works great for the first set
of OB (posted below WITH confusing issues commented out) but I an
confused as to the following:
----------------------------------------------------
Sub OptionButtonItem1to6_Click()
With Sheet4.DrawingObjects("Option Button 163")
If Sheet4.DrawingObjects("Option Button 163").Value = 1 Then
Range("INTL_FX_1to6").EntireRow.Hidden = False
Else
Range("INTL_FX_1to6").EntireRow.Hidden = True
'If Sheet4.DrawingObjects("Option Button 161").Value = 1 Then
' Range("INTL_FX_1to6").EntireRow.Hidden = True
' ElseIf Sheet4.DrawingObjects("Option Button 162").Value = 2 Then
' Range("INTL_FX_1to6").EntireRow.Hidden = True
' ElseIf Sheet4.DrawingObjects("Option Button 163").Value = 3 Then
' Range("INTL_FX_1to6").EntireRow.Hidden = False
End If
End With
End Sub
Sub OptionButtonItem7to12_Click()
With Sheet4.DrawingObjects("Option Button 196")
If Sheet4.DrawingObjects("Option Button 196").Value = 1 Then
Range("INTL_FX_7to12").EntireRow.Hidden = False
Else
Range("INTL_FX_7to12").EntireRow.Hidden = True
'If Sheet4.DrawingObjects("Option Button 196").Value = 1 Then
' Range("INTL_FX_7to12").EntireRow.Hidden = True
' ElseIf Sheet4.DrawingObjects("Option Button 196").Value = 2 Then
' Range("INTL_FX_7to12").EntireRow.Hidden = True
' ElseIf Sheet4.DrawingObjects("Option Button 196").Value = 3 Then
' Range("INTL_FX_7to12").EntireRow.Hidden = False
End If
End With
End Sub
----------------------------------------------------
1. how do I loop the macro through the the first six groups of OB to
reflect if a user has selected the 2-6 group of OB without copying and
pasting for each "Other" OB from each of the 12 sets? In order words,
what must I add to the macro to ensure that the unhidden range is
visible if either 1 or all or any combination of the "Other" OB is
selected (I assume that once a user has selected an Other OB, further
selections of the Other OB within the macro do nothing).
2. once the macro has been updated for (1) above, can it be cloned for
the second section?
3. does it seem logical to have the FX values the user keys in (once an
Other OB has been selected) cleared if a later OB from that group is
chosen. I understand how to do that with one group of OB, but given my
question in (1), will that require significant coding?
Thanks in advance,
Dylan
I require some assistance with a macro I have attempted to write to
unhide certain rows when one of three option buttons (OB) is selected.
Where I am running into problems is trying to logically determine the
code necessary to add when I have added additional groups of OB as well
as what happens/needs to happen once the rows are unhidden.
Specifically, my form is comprised of 2 sections; the 1st section is
composed of 6 groups of 3 option buttons (each group of OB corresponds
to one column of data (choices are Canada/US/Other). When a user selects
the Other option, a range of rows is unhidden underneath the 1st section
the for the user to key foreign exchange rates (note that once the user
has at least one Other OB selected, the same rows will apply to all 6
columns). The 2nd section is just a duplicate of the first allowing the
user a total of 12 possible items to key. All groups are functioning
independently and working well. My macro works great for the first set
of OB (posted below WITH confusing issues commented out) but I an
confused as to the following:
----------------------------------------------------
Sub OptionButtonItem1to6_Click()
With Sheet4.DrawingObjects("Option Button 163")
If Sheet4.DrawingObjects("Option Button 163").Value = 1 Then
Range("INTL_FX_1to6").EntireRow.Hidden = False
Else
Range("INTL_FX_1to6").EntireRow.Hidden = True
'If Sheet4.DrawingObjects("Option Button 161").Value = 1 Then
' Range("INTL_FX_1to6").EntireRow.Hidden = True
' ElseIf Sheet4.DrawingObjects("Option Button 162").Value = 2 Then
' Range("INTL_FX_1to6").EntireRow.Hidden = True
' ElseIf Sheet4.DrawingObjects("Option Button 163").Value = 3 Then
' Range("INTL_FX_1to6").EntireRow.Hidden = False
End If
End With
End Sub
Sub OptionButtonItem7to12_Click()
With Sheet4.DrawingObjects("Option Button 196")
If Sheet4.DrawingObjects("Option Button 196").Value = 1 Then
Range("INTL_FX_7to12").EntireRow.Hidden = False
Else
Range("INTL_FX_7to12").EntireRow.Hidden = True
'If Sheet4.DrawingObjects("Option Button 196").Value = 1 Then
' Range("INTL_FX_7to12").EntireRow.Hidden = True
' ElseIf Sheet4.DrawingObjects("Option Button 196").Value = 2 Then
' Range("INTL_FX_7to12").EntireRow.Hidden = True
' ElseIf Sheet4.DrawingObjects("Option Button 196").Value = 3 Then
' Range("INTL_FX_7to12").EntireRow.Hidden = False
End If
End With
End Sub
----------------------------------------------------
1. how do I loop the macro through the the first six groups of OB to
reflect if a user has selected the 2-6 group of OB without copying and
pasting for each "Other" OB from each of the 12 sets? In order words,
what must I add to the macro to ensure that the unhidden range is
visible if either 1 or all or any combination of the "Other" OB is
selected (I assume that once a user has selected an Other OB, further
selections of the Other OB within the macro do nothing).
2. once the macro has been updated for (1) above, can it be cloned for
the second section?
3. does it seem logical to have the FX values the user keys in (once an
Other OB has been selected) cleared if a later OB from that group is
chosen. I understand how to do that with one group of OB, but given my
question in (1), will that require significant coding?
Thanks in advance,
Dylan