unch80
New Member
- Joined
- Jul 30, 2008
- Messages
- 33
Hi there,
I have a wee problem with hidden rows and hiding the option buttons contained in that row. I have several questions in a sheet which depending on the answer (yes or no) will unhide rows to ask more questions.
All buttons are working OK (and have group frame around them) but when I hide the rows the options buttons remain visible. I got the code below from a previous post which works great BUT it's taking about a minute to run each time and I have about 15 'trigger' which if answered no, unhides several other rows.
Can anyone give me any tips on how I speed up the macro please?
Many thanks
Rach
Dim Rng As Range, Dn As Range
Dim shp As Shape
Set Rng = Range("F31:L105")
For Each shp In ActiveSheet.Shapes
If shp.Type = msoFormControl Then
If shp.FormControlType = xlOptionButton Then
shp.Visible = True
End If
End If
Next shp
For Each Dn In Rng
If Dn.EntireRow.Hidden = True Then
For Each shp In ActiveSheet.Shapes
If shp.Type = msoFormControl Then
If shp.FormControlType = xlOptionButton Then
If Dn.Row >= shp.TopLeftCell.Row And _
Dn.Row <= shp.BottomRightCell.Row Then
shp.Visible = False
End If
End If
End If
Next shp
End If
Next Dn
End Sub
I have a wee problem with hidden rows and hiding the option buttons contained in that row. I have several questions in a sheet which depending on the answer (yes or no) will unhide rows to ask more questions.
All buttons are working OK (and have group frame around them) but when I hide the rows the options buttons remain visible. I got the code below from a previous post which works great BUT it's taking about a minute to run each time and I have about 15 'trigger' which if answered no, unhides several other rows.
Can anyone give me any tips on how I speed up the macro please?
Many thanks
Rach
Dim Rng As Range, Dn As Range
Dim shp As Shape
Set Rng = Range("F31:L105")
For Each shp In ActiveSheet.Shapes
If shp.Type = msoFormControl Then
If shp.FormControlType = xlOptionButton Then
shp.Visible = True
End If
End If
Next shp
For Each Dn In Rng
If Dn.EntireRow.Hidden = True Then
For Each shp In ActiveSheet.Shapes
If shp.Type = msoFormControl Then
If shp.FormControlType = xlOptionButton Then
If Dn.Row >= shp.TopLeftCell.Row And _
Dn.Row <= shp.BottomRightCell.Row Then
shp.Visible = False
End If
End If
End If
Next shp
End If
Next Dn
End Sub