+ Reply to Thread
Results 1 to 16 of 16

Multiple Select Case to open exact UserForm

  1. #1
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Multiple Select Case to open exact UserForm

    Hi There...

    With the help of this Forum I have managed to get a User Form working where a selection are done through a Combo Box and based on the selection another User Form is then opened for the relevant entry.

    The code working for this selection can be seen below. The first code adds the dropdown list for an exact entry.
    Please Login or Register  to view this content.
    The second part of the code seen below opens the required User Form based on the Combo Box selection.
    Please Login or Register  to view this content.
    How do I do a multiple selection. The newly planned User Form opened will have a selection between an Area (combobox1), Employee Absent (combobox2) as well as Quantity Employees Absent (combobox3). The code for all the Combo Boxes can be seen below...
    Please Login or Register  to view this content.
    I have tried numerous ways to alter the select statement with no success. Anyone knows how to add to below code to get it to work?
    Please Login or Register  to view this content.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: Multiple Select Case to open exact UserForm

    I don't really understand what you're asking - what determines which form is loaded?

    BTW, you can simplify and speed up your code using arrays:
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: Multiple Select Case to open exact UserForm

    Quote Originally Posted by romperstomper View Post
    I don't really understand what you're asking - what determines which form is loaded?
    I would like to have at least the first 2 Combo Box selections to determine the form. The first selection (combobox1) is for the area. After this selection then only the User Form relevant to that area must be an option. Then based on the selection from combobox2 (Employees Absent Yes or No) the Form for the specific area has one User Form with no absenteeism while the other one has an option to fill in the persons absent.

    I have seen some samples on the net for Multiple Selections but could not get it to work with an exact match.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: Multiple Select Case to open exact UserForm

    Still not really clear but at a guess you mean something like this:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: Multiple Select Case to open exact UserForm

    I think your code is going the right way as it makes sense and is in line with what I saw on the net.

    At the end of the code I get an error "Compile Error: End Select without Select Case" but are not sure to what it must be changed to?

  6. #6
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Multiple Select Case to open exact UserForm

    As far as the compile error goes, you've got mis-matched control structure and are probably missing an 'End If' or 'End With'.

    Post your code exactly as you have it now...

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: Multiple Select Case to open exact UserForm

    Please copy and paste the exact code you have currently.

  8. #8
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: Multiple Select Case to open exact UserForm

    See code below...

    Please Login or Register  to view this content.

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: Multiple Select Case to open exact UserForm

    That's not my code. You are missing two End If lines there, or one and use ElseIf:
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: Multiple Select Case to open exact UserForm

    Quote Originally Posted by romperstomper View Post
    That's not my code. You are missing two End If lines there, or one and use ElseIf:
    Please Login or Register  to view this content.
    That sorted the code error out. However nothing happens as the form does not open.

    I have below code on the command button. Do I need to alter on this code?

    Please Login or Register  to view this content.

  11. #11
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: Multiple Select Case to open exact UserForm

    You need to make your criteria values lower case since you use LCase in the code...

  12. #12
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: Multiple Select Case to open exact UserForm

    Quote Originally Posted by romperstomper View Post
    You need to make your criteria values lower case since you use LCase in the code...
    LOL.... Did not even pick that up. Silly mistake on my part.

    Thank you for all the help. Even though you did not understand 100% the question I had, You still managed to solve it.
    Thank you!

  13. #13
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: Multiple Select Case to open exact UserForm

    Thread will now be marked as solved!

  14. #14
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: Multiple Select Case to open exact UserForm

    Quote Originally Posted by romperstomper View Post
    That's not my code. You are missing two End If lines there, or one and use ElseIf:
    Please Login or Register  to view this content.
    The code above now works perfect based on the "combobox1" and "Textbox_EmployeesAbsentYesNo" values. Would it be possible to add the 3rd combo box variable in above code that selects the form for the amount of employees absent? In other words the 3rd selection will only be activated if the answer to the "Textbox_EmployeesAbsentYesNo" is yes.
    Last edited by Colin Smit; 12-15-2014 at 11:28 PM.

  15. #15
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: Multiple Select Case to open exact UserForm

    Yes - you can nest another If...Then clause inside the "yes" branch.

  16. #16
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: Multiple Select Case to open exact UserForm

    Quote Originally Posted by romperstomper View Post
    Yes - you can nest another If...Then clause inside the "yes" branch.
    It works...Tks!

    I have however decided to combine the last to variables. See code below. The first selection will be for the specific area and the second one will be whether there are any individuals absent. That way I have solved the problem as well as reduced the amount of questions required to be answered. Saves time as well.

    Please Login or Register  to view this content.
    Again thank you for all the help!

+ 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] multiple if or case select
    By john55 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-08-2014, 06:56 AM
  2. [SOLVED] Case Select not catching right column in Userform's Combobox
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 05-08-2014, 02:28 PM
  3. [SOLVED] Using userform for Select Case
    By hcyeap in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-14-2014, 09:00 AM
  4. Select Case and UserForm Buttons
    By abousetta in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-29-2011, 11:35 PM
  5. Select case / case is, multiple arguments
    By Werner Rohrmoser in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-03-2006, 07:00 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