Hi all,
I'm having a hard time making this work.
I have a workbook with multiple worksheets with the same pattern: they all have four Option Buttons (Form Controls not ActiveX), I'm trying to write a macro to unselect all of them in all worksheets.
Unfortunately, they do not have the same names across all sheets so I added a workaround solution... I am able to clear the first sheet, but somehow my code is not running all workbook...
That's what I'm doing:
---------
Sub Clearoptbut()
Dim ws As Worksheet
Dim i As Long
Dim opt As String
For Each ws In ActiveWorkbook.Worksheets
For i = 5 To 12
opt = "Option Button " & i
On Error Resume Next
ws.Shapes.Range(Array(opt)).Select
On Error GoTo 0
With Selection
.Value = xlOff
' .LinkedCell = ""
' .Display3DShading = False
End With
Next
Range("c15").ClearContents
Range("a1").Select
Next ws
End Sub
--------
Any help?
Thanks!
I'm having a hard time making this work.
I have a workbook with multiple worksheets with the same pattern: they all have four Option Buttons (Form Controls not ActiveX), I'm trying to write a macro to unselect all of them in all worksheets.
Unfortunately, they do not have the same names across all sheets so I added a workaround solution... I am able to clear the first sheet, but somehow my code is not running all workbook...
That's what I'm doing:
---------
Sub Clearoptbut()
Dim ws As Worksheet
Dim i As Long
Dim opt As String
For Each ws In ActiveWorkbook.Worksheets
For i = 5 To 12
opt = "Option Button " & i
On Error Resume Next
ws.Shapes.Range(Array(opt)).Select
On Error GoTo 0
With Selection
.Value = xlOff
' .LinkedCell = ""
' .Display3DShading = False
End With
Next
Range("c15").ClearContents
Range("a1").Select
Next ws
End Sub
--------
Any help?
Thanks!