+ Reply to Thread
Results 1 to 2 of 2

VBA checkboxes

  1. #1
    Forum Contributor
    Join Date
    05-09-2005
    Location
    SC
    Posts
    196

    VBA checkboxes

    Hello again,

    I create a userform that says, "Please select a name", with about 4 selections below it using checkboxes from the toolbox.

    I want to open this input box upon opening the workbook, so that the user can make the neccessary selections. The selections shall be linked to certain cells.

    I've worked with the checkboxes on a spreadsheet, playing with formulas off of the true/false returns as boxes are checked.

    I'm shabby with the VBA codes.

    What I have so far is

    Private Sub Workbook_Open ()
    Userform1.Show

    End Sub

    How do I code the buttons to make the selections. I also have a cancel button to close the box once the selections are made.

    Thanks

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good morning Emoe

    This should get you started. In yor userform design double click on your close button. This should open a blank pane where you can put code that will be executed upon the button being clicked. Now we can look at some code that will decide what checkbuttons have been clicked. You haven't stated what the checkbuttons are to do, so in this example they will open a msgbox stating which button have been clicked:

    My assmptions are that your close button is calledCommandButton1 (the default name for a new button) and your checkboxes are called CheckBox1,2 etc. The last line will remove the userform from view. The code itself is not that tricky once you know which direction you are going in.

    Private Sub CommandButton1_Click()
    If CheckBox1.Value = True Then
    MsgBox "Checkbox 1 has been clicked"
    End If
    If CheckBox2.Value = True Then
    MsgBox "Checkbox 2 has been clicked"
    End If
    UserForm1.Hide
    End Sub

    HTH

    DominicB

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1