+ Reply to Thread
Results 1 to 17 of 17

assistance with filling listbox.

  1. #1
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    assistance with filling listbox.

    This is driving me nuts, just can't get it too work the way I want. If the name exist once it works perfect, only when the name exist twice do I have problems. For example if you type in Airport it will fill the list box with the info I want, if you type in American Pie it does not work right because their is a American Pie 2. Can this be rewrote too fix this issure or is it impossible to do what I want. Same problem with Basic Instinct because this is a Basic Instinct 2 .

    Thanks Z
    Attached Files Attached Files
    Last edited by zplugger; 02-09-2011 at 04:49 PM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: assistance with filling listbox.

    Hi Z,

    I think this is the way most combo/list boxes work. It will go to what you type until it doesn't match. You need to get to the space after American Pie before it knows you want to go onto 2.

    What did you expect to happen?

    Here is an example. Create two named ranges. Range1 and Range2. Now start doing a formula that takes a range, say Countif( ... You go to a cell and start typing a formula "=Countif(Rang...) and see that both Range1 and Range2 are still available. It doesn't know you want Range2 until you get to the first character (the 2) that is different.

    I think it works as it should.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: assistance with filling listbox.

    Hello again Marvin
    What I expected is after american pie is found in the Combobox it fill the listbox with info. When you type in other names it will fill as soon as it finds the name. I guess I don,t understand why american pie does not fill listbox. If I delete american pie 2 it works ok. As soon as I type american pie it comes up in combobox but not list box.

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

    Re: assistance with filling listbox.

    Maybe VBA can help.
    This is the only code you need in Userform2

    Please Login or Register  to view this content.



  5. #5
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: assistance with filling listbox.

    Thanks snb you and marvin were a great help on this. All I have to do now it get the listbox to clear when I exit the form.
    Z

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

    Re: assistance with filling listbox.

    Listboxes clear when the form is closed
    Hope that helps.

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

    Free DataBaseForm example

  7. #7
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: assistance with filling listbox.

    Listbox is not clearing on close, holding value for some reason.

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

    Re: assistance with filling listbox.

    Hide<>Close

    Unload = Close

  9. #9
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: assistance with filling listbox.

    Thanks snb do I put this in Private Sub UserForm_Initialize()

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

    Re: assistance with filling listbox.

    When you close the Userform then the controls clear.

    When it opens again the form is reloading with the data as it should according to the initialize code provided by snb

    If you want the controls to not display a value then amend the code like this
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: assistance with filling listbox.

    Hi Roy

    When I try and use that code I get Run-Time Error Object Required.


    I made a change here .ListIndex = combox1.ListIndex
    .ListIndex = combobox1.ListIndex

    Still does not clear form on startup.
    Last edited by zplugger; 02-09-2011 at 01:53 PM.

  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: assistance with filling listbox.

    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!

  13. #13
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: assistance with filling listbox.

    Here it is Roy
    Everthing works ok except when you open the form the list box has data. Userform 2 is the problem one.
    Attached Files Attached Files

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

    Re: assistance with filling listbox.

    Roy had a typo:
    Please Login or Register  to view this content.
    should be
    Please Login or Register  to view this content.
    you must be able to debug typos yourself.

  15. #15
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: assistance with filling listbox.

    Hello snb I fixed the type o and still does not clear on open

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

    Re: assistance with filling listbox.

    Look in VBEditor's for nomenclature.
    Clear in a Listbox or combobox has a special meaning, do not use it if you mean: the listbox shouldn't show anything at teh beginning

    This solves your problem:
    Please Login or Register  to view this content.
    But for your purpose 2 comboboxes would be more approriate:
    Please Login or Register  to view this content.

    doesn

  17. #17
    Forum Contributor
    Join Date
    03-05-2009
    Location
    usa
    MS-Off Ver
    Excel 2016 32Bit
    Posts
    1,173

    Re: assistance with filling listbox.

    Thank You Very much for all your help Guys, this is what I was looking for. I will study the codes better to understand them.
    Z

+ 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