+ Reply to Thread
Results 1 to 24 of 24

filling listbox from userform combobox problem

  1. #1
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    760

    filling listbox from userform combobox problem

    hi
    iam having bit of problem filling a multiple listbox ,my combobox fills all textboxes ok but can not seem to get listbox working,the idea should be to pick number from combobox and populate listbox,say d101 is picked there can be more than one d101, so you can pick one populated in listbox ,which then sends to textboxes the one you picked,hope that makes sense,any help in direction to take please
    cheers colin
    Attached Files Attached Files
    Last edited by cfinch100; 07-06-2013 at 04:56 PM.

  2. #2
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    760

    Re: filling listbox from userform combobox problem

    hi
    I have now got the listbox to populate but it is independent from the textboxes not sure where to go from here its just listing what is on the sheet by looks
    cheers colin
    Attached Files Attached Files

  3. #3
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: filling listbox from userform combobox problem

    Is the combination of Unit and plant number a unique identifier?
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    Re: filling listbox from userform combobox problem

    If you want to populate the listbox based on the choice in the combobo why is the code to populate it in the form's Initialize event.

    The code should go in the combobox change event, and the code to populate the textboxes should go in the listbox's change or (double) click event.
    If posting code please use code tags, see here.

  5. #5
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    760

    Re: filling listbox from userform combobox problem

    hi
    the plant number is unique but I may have 2 or 3 for different cranes ,and yes I can only find d101 on unit 100 nowhere else, eg plant no d101 on unit 100 ,200ton crane / d101 on unit 100, 100ton crane
    hope that explains a bit
    cheers colin

  6. #6
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    760

    Re: filling listbox from userform combobox problem

    hi norie
    probably cos I aint very bright
    have changed that but if double click on selection would like it to send to textboxes
    cheers colin

  7. #7
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: filling listbox from userform combobox problem

    in post #1
    say d101 is picked there can be more than one d101
    and then
    the plant number is unique
    now I am confused as your example file shows no duplicate plant numbers.

    You have a combobox with unique idenfiers (listing plant number), what was the sense of the listbox again?

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    Re: filling listbox from userform combobox problem

    Colin

    What exactly do you have now?

  9. #9
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    760

    Re: filling listbox from userform combobox problem

    hi
    sorry forgot to put duplicate in,have done d101 now, the idea is I put plant number in combobox and populate the listbox with all cranes associated with that number and double click the row required in the listbox to populate the above textboxes with the one selected,i might have 2 or 3 different cranes/ configurations for plant numbers,eg d101 I might have to use 95t crane or 200ton crane depending on cicumstances
    and availability of cranes
    cheers colin
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    760

    Re: filling listbox from userform combobox problem

    hi norie
    have uploaded latest one
    cheers colin

  11. #11
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: filling listbox from userform combobox problem

    try VlookupLIFTPLAN_1.xlsm

    subs changed:
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    760

    Re: filling listbox from userform combobox problem

    hi tehnexus
    that's excellent exactly what I wanted it to do many thanks for help,even though mine was not very good by looks of it
    cheers colin

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    Re: filling listbox from userform combobox problem

    Colin

    Populate the textboxes from the listbox, not the sheet.
    Please Login or Register  to view this content.
    Last edited by Norie; 07-06-2013 at 05:30 PM.

  14. #14
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: filling listbox from userform combobox problem

    You are totally correct Norie.

    No idea why I was checking the sheet and then taking the listbox values, does not make sense at all.

  15. #15
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    760

    Re: filling listbox from userform combobox problem

    hi norie
    many thanks
    cheers colin

  16. #16
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    Re: filling listbox from userform combobox problem

    tehneXus

    I was totally confused trying to figure out how you were correctly populating the textboxes.

    I stepped through the code multiple times until I realised you were using the Listtbox.

  17. #17
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    760

    Re: filling listbox from userform combobox problem

    hi tehnexus
    not sure what I have done but comes up with can not set list property have stepped through quite a few times and come up with nothing,i added a couple of command buttons which work and a hyperlink,it was when I added textbox10 ,additional info that started to go wrong but if I take it out it does the same,any idea as to what I have done please
    Please Login or Register  to view this content.
    stops here
    cheers colin
    Attached Files Attached Files

  18. #18
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626
    Colin

    You can't use AddItem when there are more than 9 columns.

    What you can do is create an array with the data for the listbox and then use List to populate.

  19. #19
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    760

    Re: filling listbox from userform combobox problem

    hi norie
    thankyou ,clear as mud ,but ill give it a go
    cheers colin

  20. #20
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626
    Colin

    Its quite straightforward really.

    Something like this very rough code.
    Please Login or Register  to view this content.

  21. #21
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    Re: filling listbox from userform combobox problem

    This works but the column widths aren't right.
    Please Login or Register  to view this content.

  22. #22
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    760

    Re: filling listbox from userform combobox problem

    hi norie
    have put code in module but does not seem to work,do I need to take any code out ,been at arrays for 4 hrs and brain is numb
    cheers colin

  23. #23
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    Re: filling listbox from userform combobox problem

    That code would replace the code in the combobox change event that is populating the combobox.
    Please Login or Register  to view this content.
    Remember though, I've not got the column widths, or possibly not even the columns to be displayed, quite right.

    You'll need to fix that yourself, or give more details.

  24. #24
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    760

    Re: filling listbox from userform combobox problem

    hi
    many thanks
    cheers colin

+ 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