Consulting

Results 1 to 8 of 8

Thread: Solved: Check Box

  1. #1
    VBAX Mentor
    Joined
    Nov 2008
    Posts
    305
    Location

    Solved: Check Box

    I've created some checkboxes on a worksheet.
    I need to write some code to remove the check in the checkboxes.
    Can anyone tell me how I call the checkboxes in VBA, and remove the check mark?

    Thanks

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    [vba]Sub ResetAllCheckBoxesInUserForm()
    Dim ctrl As Control
    For Each ctrl In UserForm1.Controls
    If TypeName(ctrl) = "CheckBox" Then
    ctrl.Value = False
    End If
    Next ctrl
    End Sub[/vba]

    This works on a userform. Change the userform1 to the sheet where you have the checkboxes:

    [VBA] ActiveWorkbook.Sheets("shtname").Controls[/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    VBAX Mentor
    Joined
    Nov 2008
    Posts
    305
    Location
    The checkboxes aren't on a userform, they are on a worksheet called "SOP"

    I'm getting a runtime error: Object doesn't support this property or method.

    Im using Excel 2003.
    Last edited by ukdane; 02-06-2009 at 09:42 AM. Reason: Code in reply doesn't work

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I'm sorry, I need more coffee this morning. Are they activeX checkboxes or are they from the forms toolbar?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    VBAX Mentor
    Joined
    Nov 2008
    Posts
    305
    Location
    They are from the forms toolbar.

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Dim cb As CheckBox

    For Each cb In ActiveSheet.CheckBoxes

    cb.Delete
    Next cb
    Dim cb As CheckBox
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    or
    [VBA]cb.Value = False[/VBA]
    if you just want to clear the checkmark
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  8. #8
    VBAX Mentor
    Joined
    Nov 2008
    Posts
    305
    Location
    Super, thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •