• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need Better code for Setting defaults for option/check box

Hello Friends,

Need your help in altering/ amending the vba code for the sub routine AnswerDefaults

Attached file for your reference.

Regards,
Pavan S
 

Attachments

  • Cemex Assessment.xlsm
    330.7 KB · Views: 2
Hi Pavan

Give the following a try. Should clear all of your controls.

Code:
Option Explicit
Sub ClearSht()
Dim i As Integer
Dim sh As Worksheet
Set sh = Sheet3

    For i = 1 To sh.OLEObjects.Count
        If TypeName(sh.OLEObjects(i).Object) = "OptionButton" Or TypeName(sh.OLEObjects(i).Object) = "CheckBox" Then
            sh.OLEObjects(i).Object = 0
        End If
    Next i
End Sub

Take care

Smallman
 
Hey SmallMan,

Code worked great. But have a small qualm in my mind.. Will it also work for the option box inserted through Form controls

Regards,
Pavan
 
Here is what I did. I took your speadsheet and I made sure the code worked on all objects on the sheet. I checked it before I posted my coding and it worked well on all your objects.

It is late here in Oz and I am going to get hit by the Sandman. Someone on the night shift will be able to assist.

Take care

Smallman
 
Back
Top