+ Reply to Thread
Results 1 to 18 of 18

Two Combo boxes on one UserForm

  1. #1
    Registered User
    Join Date
    06-19-2010
    Location
    Bangkok, Thailand
    MS-Off Ver
    Excel 2003, 2007
    Posts
    18

    Two Combo boxes on one UserForm

    Hi! I'm new here, please forgive me if I post this thread at the wrong place.

    I'm working on a UserForm with 2 combo boxes which are named "Room Type" and "Room No". What I want to do is when I select something in "Room Type", it limits the choices to be displayed in "Room No.".

    EXE (Executive Suites) = 1, 2, 8, 9
    JUN (Junior Suites) = 3, 5, 7
    DLX (Deluxe Suites) = 4, 6

    I created a table in a worksheet called "ROOM" with 2 columns, column A is for room types. Column B from B2 to B100 are room no. for 901 to 909, 1001 to 1009, 9 rooms each floor up to 2009.. So, if column B = 901, column A = EXE

    For example;

    Combo box "Room Type" = DLX
    Combo box "Room No." displays 904, 906, 1004, 1006, 1104,1106,... up to 2006

    If you get my point, please give me some clue. Thank you
    Last edited by NonSira; 06-23-2010 at 03:12 AM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Two Combo boxes on one UserForm

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!

  3. #3
    Registered User
    Join Date
    06-19-2010
    Location
    Bangkok, Thailand
    MS-Off Ver
    Excel 2003, 2007
    Posts
    18

    Re: Two Combo boxes on one UserForm

    Sorry for not attaching any file, I will create a file and attach next time.
    Nontpakorn
    Last edited by NonSira; 06-22-2010 at 02:03 AM.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Two Combo boxes on one UserForm

    Use the post reply button, then go advanced. Scroll down the page & you will find a button labelled manage attachments,click it & browse for your folder

    It depends how you are adding the lists to the Comboboxes for the best way to do this
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    06-19-2010
    Location
    Bangkok, Thailand
    MS-Off Ver
    Excel 2003, 2007
    Posts
    18

    Re: Two Combo boxes on one UserForm

    Hi!

    I have done a very simple file and I think you could understand it perfectly!

    You can see that I put 2 combo boxes on the UserForm and they show data from the selected sources. When I select Room Type "EXE", I want the Room No. combo box to show only the numbers that belong to "EXE" category.

    Appreciated every assistance

    Nontpakorn

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Two Combo boxes on one UserForm

    There's no file attached.
    Remember what the dormouse said
    Feed your head

  7. #7
    Registered User
    Join Date
    06-19-2010
    Location
    Bangkok, Thailand
    MS-Off Ver
    Excel 2003, 2007
    Posts
    18

    Re: Two Combo boxes on one UserForm

    Ah! I missed again.

    It should be good this time.
    Attached Files Attached Files

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Two Combo boxes on one UserForm

    The code for your form becomes something like this:
    Please Login or Register  to view this content.

  9. #9
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Two Combo boxes on one UserForm

    For this task you only need 1 combobox. See the attachment.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    06-19-2010
    Location
    Bangkok, Thailand
    MS-Off Ver
    Excel 2003, 2007
    Posts
    18

    Re: Two Combo boxes on one UserForm

    Thank you for all your kind assistance.

    @romperstomper

    An error displayed after I tried selecting the Room Type

    "Run-time error '-2147467259 (80004005)':
    Unspecified error

    What does it mean?

  11. #11
    Registered User
    Join Date
    06-19-2010
    Location
    Bangkok, Thailand
    MS-Off Ver
    Excel 2003, 2007
    Posts
    18

    Re: Two Combo boxes on one UserForm

    snb,

    I prefer to have two separated controls. But thank you so much for your effort.

  12. #12
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Two Combo boxes on one UserForm

    Don't know (it's unspecified! )
    It worked fine in my test - are you using it in a different workbook than the one you posted? If so, can you test it in the one you posted, please?

  13. #13
    Registered User
    Join Date
    06-19-2010
    Location
    Bangkok, Thailand
    MS-Off Ver
    Excel 2003, 2007
    Posts
    18

    Re: Two Combo boxes on one UserForm

    I tried it on the same workbook. I thought it was because Windows 7, but after I tried it on XP PC I got the same problem.

  14. #14
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Two Combo boxes on one UserForm

    I think our users will prefer 1 combobox.
    If you choose EXE you will see all EXE rooms. If you want to change to JUN, you select the first item EXE, then you will see the original list with EXE DLX and JUN. If you choose JUN you'll get the list with JUN rooms.

  15. #15
    Registered User
    Join Date
    06-19-2010
    Location
    Bangkok, Thailand
    MS-Off Ver
    Excel 2003, 2007
    Posts
    18

    Re: Two Combo boxes on one UserForm

    @snb

    When we make the hotel reservation, we have to choose the room type but we don't know yet what room no. That's why I want them to be separated

  16. #16
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Two Combo boxes on one UserForm

    There's no obligation to choose a roomnumber

    In the code for the commandbutton:

    Please Login or Register  to view this content.
    That means: in columnB there will be the room type; in column C the room number

  17. #17
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Two Combo boxes on one UserForm

    Sorry, I just twigged the problem. I forgot to mention that you need to clear the RowSource property of the cmbROOM control.

  18. #18
    Registered User
    Join Date
    06-19-2010
    Location
    Bangkok, Thailand
    MS-Off Ver
    Excel 2003, 2007
    Posts
    18

    Re: Two Combo boxes on one UserForm

    Thank you for both of you, both of your suggestions work perfectly!

+ 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