Clearing Option Buttons

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a set of 80 Option Buttons (from Control Toolbox) in a questionaire.
I want to clear all of them after a macro posts the results to another sheet.
I can clear them individually with this line in my code like this (for
Option Button 79):

ActiveSheet.OptionButton79.Object.Value = False

For some reason, if I generalize this by trying to clear them with a loop,
it fails.
Here is the code I have tried unsuccessfully to use:

Sub ClearOptBut()
Dim i As Integer
For i = 1 To 80
ActiveSheet.OptionButton(i).Object.Value = False
Next i
End Sub

It hangs up on

ActiveSheet.OptionButton(i).Object.Value = False
 
Hi
try (not tested):
Sub ClearOptBut()
Dim i As Integer
For i = 1 To 80
with ActiveSheet.controls("OptionButton" & i)
.Value = False
end with
Next i
End Sub
 

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

Back
Top