+ Reply to Thread
Results 1 to 10 of 10

Creating a User Form with variable number of Controls buttons

  1. #1
    Registered User
    Join Date
    08-30-2005
    Posts
    67

    Post Creating a User Form with variable number of Controls buttons

    Hi All,

    Is it at all possible to create a User Form where the number of CheckBoxes will be linked to the number of entries in a cell range?

    For example I have a 3 records in the range A:A called "Blue", "Green", "Yellow". I want to have a user form with 3 CheckBoxes with the same caption names.

    Please note the number and name of records in this range may vary.

    Thanks,
    Eduard

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Eduard,

    Yes, you can create controls dynamically on both a VBA UserForm and also on a worksheet. It isn't clear if your are referring to a worksheet as a user form or not. Let me know if your controls are on a worksheet or VBA UserForm.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    04-24-2008
    Location
    Zurich
    Posts
    45
    You may create a userform with lets say 10 checkboxes and assign the code below to the userform. You have to verify the item indices of the checkboxes (under properties listed as TabIndex). The code as it is assumes index 0 to 9 for the 10 checkboxes.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    08-30-2005
    Posts
    67
    Thanks Kuskush! This code might do for a while.

    Would there be a more practical solution? Cause I don't want to create a VBA User Form with 100 checkboxes just to make sure that all the records are picked up. Besides that the size of such a User Form will be not very "user-friendly". And the boxes will be dispersed all other the form.

  5. #5
    Registered User
    Join Date
    08-30-2005
    Posts
    67
    Dear Kuskush,

    I have one more thing to ask, if you don't mind.

    Would it be possible to run a User Form after or within the a macro?

    What I'm trying to get, if to take your example, is to sort the cells A1:A10 first and after that the User Form to pop up.

    Thanks,
    Eduard
    Attached Files Attached Files

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,480
    I prefer the listbox approach to this problem where number of entries is variable.

    Add a listbox to the userform with this code added to the Initialize event.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  7. #7
    Registered User
    Join Date
    08-30-2005
    Posts
    67
    Thanks Andy. That's a good solution. I was not sure the list box will give me the multiple selection choise. Seems like it's all possible.

    Still, I'm trying to figure out where do I have to put the code to sort the data prior to the form being initialized.

    Thanks beforehand for any advise.

    Eduard

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,480
    Either in the initalize event, before the code to deal with checkboxes/listbox.
    Or in the Click event of the button

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-24-2008
    Location
    Zurich
    Posts
    45
    Try this:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    08-30-2005
    Posts
    67
    Thanks, Guys. It works either way for me.

+ 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. VLOOKUP Funtion within a User Form
    By bern in forum Excel General
    Replies: 4
    Last Post: 01-06-2016, 06:11 AM
  2. User form problems
    By lapot in forum Excel General
    Replies: 4
    Last Post: 12-15-2006, 02:02 PM
  3. replacing values in a variable number of columns
    By mwc0914 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-07-2006, 10:42 PM
  4. possible to delay comments until user form receives input?
    By noisepoet in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-28-2006, 01:47 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