Consulting

Results 1 to 4 of 4

Thread: Solved: Checkbox confirmation

  1. #1
    VBAX Newbie
    Joined
    Mar 2008
    Posts
    3
    Location

    Solved: Checkbox confirmation

    Hi, I've been asked at work to take over the updating of an excel VBA form and while i have a fair bit of experience with excel i don't have any with VBA. I'm confident i'll pick it up quickly (or at least what i need quickly) but i need to get this first change done asap.

    On a UserForm there is one checkbox. When this is clicked i would like to have another UserForm come up with a confirmation statement on it and Yes or No command buttons. Yes and the tick stays in the checkbox, No and the tick is removed.

    Can someone point me in the right direction for the VBA code to put in / take out the tick please?

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    You wouldn't need another Userform, a Message Box should serve.

    Put this in the Userform's code module and it will inquire any time the checkbox is changed.
    Private Sub CheckBox1_Click()
    Me.CheckBox1.Value = (MsgBox("Do you want the check box checked?", vbYesNo) = vbYes)
    End Sub
    This will inquire when the box is checked, but will not inquire when un-checking the box.
    Private Sub CheckBox1_Click()
    With Me.CheckBox1
        If .Value Then .Value = (MsgBox("Do you want the check box checked?", vbYesNo) = vbYes)
    End With
    End Sub

  3. #3
    VBAX Newbie
    Joined
    Mar 2008
    Posts
    3
    Location
    Thanks Mike. Just what i was looking for. Once pointed in the right direction i found some more examples and customised the Message Box.
    Had the meeting at work for it today and was told this change was exactly what they wanted.

    Cheers Mike

  4. #4
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Glad to have helped.

Posting Permissions

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