+ Reply to Thread
Results 1 to 4 of 4

Userform listbox with checkboxes

  1. #1
    Registered User
    Join Date
    10-01-2012
    Location
    Canada
    MS-Off Ver
    Office365 32-bit
    Posts
    28

    Userform listbox with checkboxes

    This might not be possible, but I figure there's no harm in asking. I would like to have listbox where the user can select multiple items; this is easy. What I suspect is not so easy is for it to also have "special" checkboxes, and by this I do not mean selecting fmListStyleOption from the ListStyle property. What I need is for the user to be able to select items but, depending on whether the checkbox next to the selected item is checked or not, the macro will do some extra "stuff" (extra formatting or a different calculation, etc, etc). In other words, I would like the user to be able to check/uncheck the checkboxes independently from the item selection.

    As a workaround, I've programmed the Userform_Activate event to dynamically add individual checkboxes next to the listbox based on the number of listbox items, but the spacing is often not quite right (especially when run on other people's computers) so a lot of the time the listbox items don't line up with the checkboxes correctly making it a pain to ensure that the right checkbox was checked.

    Thanks!
    Alex

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Userform listbox with checkboxes (... not the ones you're thinking of)

    I would suggest you have a two column listbox. The first column have your items and the second column have what to do with that item. So the user selects an item then selects from say three option buttons what to do with the currently selected item. When an option is selected, it is stored in column 2 of the listbox for the selected item. You can use the same three option buttons for any selected item. They only are used to put the selected option in column two for the currently selected item.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    10-01-2012
    Location
    Canada
    MS-Off Ver
    Office365 32-bit
    Posts
    28

    Re: Userform listbox with checkboxes (... not the ones you're thinking of)

    Thanks AlphaFrog! That's a great idea! Actually, I'll modify it to take advantage of the listbox's double-click event and skip the option buttons since I only need a single yes/no option for now. I'll keep it in mind, though, in case the need for more options ever comes up.

    Cheers,
    Alex

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Userform listbox with checkboxes

    Glad it works for you.

    You could have the double-click cycle through more than two options. Five or more options would be a lot clicking though.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Toggle between userform checkboxes for multiple pairs of checkboxes
    By L plates in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-25-2016, 06:31 AM
  2. [SOLVED] if anything in listbox select first item, if listbox empty do nothing (listbox in userform
    By mcdermott2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2015, 12:49 PM
  3. [SOLVED] copy contents of userform listbox to another userform listbox
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-04-2014, 11:39 AM
  4. Transfer Data From One Userform Listbox to Another Userform Listbox with 11 columns
    By sparkoft in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-18-2013, 10:54 AM
  5. Print Sheets based on checkboxes in UserForm, Checkboxes also control another macro
    By krackaberr in forum Excel Programming / VBA / Macros
    Replies: 34
    Last Post: 03-05-2013, 11:12 AM
  6. Listbox to Listbox, no duplicates & submitting same UserForm data for each Listbox entry.
    By jamieswift1977 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2012, 12:18 PM
  7. Listbox with checkboxes
    By timbim in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-03-2009, 04:25 AM

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