+ Reply to Thread
Results 1 to 31 of 31

Multi List Box in User Form

  1. #1
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Multi List Box in User Form

    Hi, the attached WB shows 2 sheets (estimate) and (rate table) What I am trying to achieve is that : User selects button "rate table" this pops up user form 1 on estimate sheet (keeping rate table sheet hidden), the user form contains a multi list box which populates from rate table D2:D51 (4 columns) the user selects what items he/she requires then presses enter button. The selected items then populate estimate sheet finding the next 'free' row from 32 onwards. I would like to keep the rate table sheet very hidden at all times.

    Not sure if this can be done?

    Thanks in advance
    Chris.
    Attached Files Attached Files
    Last edited by zimbo109; 04-29-2010 at 11:40 AM.

  2. #2
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Multi List Box in User Form

    Sorry! just spotted here the columns from rate table do not match the same columns on estimate sheet. It should be that rate table column D goes to Estimate sheet A, E to S, F to B and G to Q. If easier then Rate table can be switched around to match that of the estimate sheet.

  3. #3
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: Multi List Box in User Form

    You were pretty much there.

    If the rateTable is always hidden don't use a name with spaces in it (it just makes things easier):

    The row source is : Ratetable!D2:G51

    You can hide the ratetable by seting the visible property of the sheet to xlsheethidden or xlsheetveryhidden


    click on the * Add Reputation if this was useful or entertaining.

  4. #4
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Multi List Box in User Form

    Thanks Tony, I don't think i'm nearly there as I don't have the abilities to create the code for copying the selected items from the list box to the estimate sheet! However that has solved part of my query - I could'nt get the row source to identify the sheet have tried everything in there - omitting the space works perfectly - thank you.

    Chris
    Last edited by zimbo109; 04-10-2010 at 04:39 AM.

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

    Re: Multi List Box in User Form

    Have a look at the attached workbook
    Attached Files Attached Files
    Hope that helps.

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

    Free DataBaseForm example

  6. #6
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: Multi List Box in User Form

    Also the code for copying the data across goes on the button click event can be of the for:

    Please Login or Register  to view this content.
    This just copies the first item but just repeat the last line for any others

  7. #7
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Multi List Box in User Form

    Thank you both - that's nearly what I'm looking for, but I would like a multi selection list box with list style option, then to copy all the selected data over.

  8. #8
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Multi List Box in User Form

    This is what I have thus far.....
    Attached Files Attached Files

  9. #9
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: Multi List Box in User Form

    Quote Originally Posted by zimbo109 View Post
    to copy all the selected data over.
    Just to be (pedantically) clear.
    Selecting an item in the list box only selects the item in the list box which is a single string.

    Using the code from my last post :
    - rngOut points a range object at the equivalent line on RateTable.
    - rngIn points to the first free line on Estimate

    (actually the first cell on the line)

    so using rngout.offset... = rngIn.offset... you can copy cells from RateTable to Estimate

    I have done the first one for you. Just repeat the line changing the offset values

  10. #10
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Multi List Box in User Form

    Lost me a bit there!!! Sorry Tony ,thank you for your help on this but I don't understand.

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

    Re: Multi List Box in User Form

    I've added code to the enter button,it allows multiple selections & enters to the form.The code prompts for a quantity& enters. It also allows for the merged cells.
    Attached Files Attached Files

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

    Re: Multi List Box in User Form

    Here's an explanationof the Enter code,forgot to add it to workbook
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Multi List Box in User Form

    That is excellent - Roy thank you, will transfer this into my working schedule and hope it works.

    Thank you Tony as well.

    Regards
    Chris

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

    Re: Multi List Box in User Form

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  15. #15
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Multi List Box in User Form

    Hi Roy,

    This is working really nicely, 2 things:
    1/ I'm getting a mismatch error on the last line of your code (think it has something to do with the protection?)
    2/ If qty box is cancelled then a run time error is produced.

    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Multi List Box in User Form

    Sorry....also the source for the list box captures the entire page, I need rows 2 to 51 only, because I will have to create more forms using this template from rows 51 onwards.

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

    Re: Multi List Box in User Form

    This will stop the mismatch error
    Please Login or Register  to view this content.
    I can't duplicate the other problem,although the End IF on your highlighted row should be on the next line

  18. #18
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Multi List Box in User Form

    Thanks Roy,

    Any luck with only populating the list box with just rows 2-51?

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

    Re: Multi List Box in User Form

    The ListBox shouldn't populate from whole page,it uses CurrentRegion. Set the rowsource to your needed range

  20. #20
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Multi List Box in User Form

    All done and working great - thank you again for your excellent help

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

    Re: Multi List Box in User Form

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  22. #22
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Multi List Box in User Form

    Roy, Just having a thought on this. Once the user has selected items on the list, is it possible to list the item with the enter quantity? Because if several items have been selected it is difficult for the user to determine what item he/she is entering the qty against.

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

    Re: Multi List Box in User Form

    It might be better to add the selected items to another listbox

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

    Re: Multi List Box in User Form

    Try this, I've added a second Listbox to store the selection in
    Attached Files Attached Files

  25. #25
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Multi List Box in User Form

    Roy, thank you for your help on this. Is there a way of being able to enter the qty against the item? This is much better and you can see what I'm trying to achieve however if many items are selected the user could lose track of where they are when entering the qty.

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

    Re: Multi List Box in User Form

    You would need to add a new column to the ListBox & change the code to amend the ListBox. I thought the second ListBox gives the user the chance to review the selection& add the quantities, an option to remove an item from the second Listbox could be added

  27. #27
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Multi List Box in User Form

    The second listBox is an excellent idea, the extra column would be the entry for the qty, and the option to remove an item would also give the user greater flexibilty. I don't know if it would be possible, but rather than have a second listBox the selections could populate a userform where the qty could be added?

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

    Re: Multi List Box in User Form

    I can't see why you need another userform.

    You could probably add a column to the ListBox then add the quantity tothat,but it would mean a lot morecoding

  29. #29
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Multi List Box in User Form

    It would be perfect to have another column in the ListBox that the user could enter a qty in. The second userform was only an idea but as you rightly say unecessary if the extra column was added. The coding to do this would be way beyond what I'm capable of writing!!

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

    Re: Multi List Box in User Form

    I'll have a look when I can,busy at the moment

  31. #31
    Forum Contributor
    Join Date
    02-05-2010
    Location
    Exeter, England
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    180

    Re: Multi List Box in User Form

    Ok thanks, it would be good to get this working.

+ 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