Clear option buttons

mpatino

Board Regular
Joined
Jul 8, 2009
Messages
82
Hi Experts,

I recorded a macro to clear all active option buttons from my worksheet, but I was wondering if someone could help me do this in a couple of lines:

ActiveSheet.Shapes.Range(Array("Option Button 53")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$8"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 55")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$8"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 60")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$9"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 61")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$9"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 66")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$15"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 67")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$15"
.Display3DShading = True
End With
ActiveWindow.SmallScroll Down:=9
ActiveSheet.Shapes.Range(Array("Option Button 69")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$19"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 70")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$19"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 72")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$20"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 73")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$20"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 75")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$26"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 76")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$26"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 78")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$30"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 79")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$30"
.Display3DShading = True
End With
ActiveWindow.SmallScroll Down:=15
ActiveSheet.Shapes.Range(Array("Option Button 81")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$33"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 82")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$33"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 84")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$36"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 85")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$36"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 87")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$42"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 88")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$42"
.Display3DShading = True
End With
ActiveWindow.SmallScroll Down:=6
ActiveSheet.Shapes.Range(Array("Option Button 90")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$48"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 91")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$48"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 93")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$54"
.Display3DShading = True
End With
ActiveSheet.Shapes.Range(Array("Option Button 94")).Select
With Selection
.Value = xlOff
.LinkedCell = "$XFC$54"
.Display3DShading = True
End With
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Fill the array by my example (since I took only two option buttons):
Code:
Sub FFF()


    Dim i, j, arr, inner_arr
    Dim optB
    
    arr = Array( _
        Array("$XFC$8", "Option Button 53", "Option Button 55"), _
        Array("$XFC$9", "Option Button 60", "Option Button 61"))
    
    With ActiveSheet
        For Each inner_arr In arr
            For i = 0 To 2
                For j = 1 To 2
                    With .OptionButtons(inner_arr(j))
                        .Value = xlOff
                        .LinkedCell = inner_arr(0)
                        .Display3DShading = True
                    End With
                Next
            Next
        Next
    End With


End Sub
 
Upvote 0
Thanks a lot Sektor, that worked pretty well, could you also help me with this?

ActiveWindow.SmallScroll Down:=-42
Rows("9:18").Select
Selection.EntireRow.Hidden = True
Rows("20:29").Select
Selection.EntireRow.Hidden = True
Rows("31:41").Select
Selection.EntireRow.Hidden = True
Rows("43:47").Select
Selection.EntireRow.Hidden = True
Rows("49:53").Select
Selection.EntireRow.Hidden = True
Rows("55:59").Select
Selection.EntireRow.Hidden = True
ActiveWindow.SmallScroll Down:=-9
 
Upvote 0
Range("9:18,20:29,31:41,43:47,49:53,55:59").EntireRow.Hidden = True
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top