+ Reply to Thread
Results 1 to 7 of 7

populate userform listbox from textbox input

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

    populate userform listbox from textbox input

    hi
    my userform3 has textbox and a listbox as i enter number in textbox it populates listbox but not with highlighted rows though,think it has something to do with range but have tried many changes and can not get right,any ideas please
    cheers colin
    Attached Files Attached Files
    Last edited by cfinch100; 04-05-2013 at 10:05 AM.

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

    Re: populate userform listbox from textbox input

    Colin

    Where are you trying to populate the listbox from? It appears to be a range with only 3 cells, A3, C3 and E3.

    By the way, have you considered using a combobox instead of a textbox?

    It could list all the unique codes/IDs/things, whatever it is that the user is mean to enter.

    The reason I suggest that is because the textbox change event is triggered after every keystroke.

    So, for example, if I enter ST0200 the code will have been executed 5 times before I've entered in the full code.

    With a combobox you can add code to see if the user has selected or typed a value on the list, and if they have run the code to populate the listbox.
    If posting code please use code tags, see here.

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

    Re: populate userform listbox from textbox input

    hi norie
    combobox sounds the way to go ,i am trying to populate the listbox from sheet4 but only the highlighted entries , so if i enter st0200 it populates those entries
    or st0199 it does those ,hope this helps
    cheers colin

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

    Re: populate userform listbox from textbox input

    Colin

    Here you go, this replaces all the code for UserForm3.

    It's not quite complete as I've not added code to set the widths of the columns in the listbox, I just set it's ColumnCount to 3.
    Please Login or Register  to view this content.
    PS I've also used something kind of new, to me anyway, to find the rows matching the selected ID. It seems to have worked, but the code can always
    be changed back to use another method.

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

    Re: populate userform listbox from textbox input

    hi nny thanks
    colinorie
    thanks for this,it only pops first colomn in listbox but will have play with it and see how i get on, ma

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

    Re: populate userform listbox from textbox input

    The code is there to populate the other columns.

    Did you change the ColumnCount of the listbox like I did?

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

    Re: populate userform listbox from textbox input

    hi norie
    excellent as always many thanks for that will populate later with extra colomns
    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