+ Reply to Thread
Results 1 to 10 of 10

Populating a listbox based on column of first listbox

  1. #1
    Registered User
    Join Date
    01-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    30

    Populating a listbox based on column of first listbox

    Hi,

    I have two listboxes in the same userform. In listbox1 are the titles of every column in the spreadsheet. Each column contains many cells but they are just repeats of two different values, for example "test1" and "tes2". I want the second listbox to display a summary of the two options, that is "test1" and "test2", but I do not want replicates of them. I have attached a sample input. Thanks for your help in advanced!
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,570

    Re: Populating a listbox based on column of first listbox

    You posted a one sheet workbook with no user forms. The workbook looks like you spent about 15 - 20 seconds on it. So, I guess you want some one to develop a complete project for you.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    01-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    30

    Re: Populating a listbox based on column of first listbox

    I posted that worksheet as a sample input, and you are correct, I did not spend very long on it. The overall project, is much, much larger (comprising around 20 forms) so it would not really be appropriate to post that. I do not by any means want somebody to do a complete project. I was looking for ideas in how to accomplish that task. I have attached what I had so far of the userform that I described above but it is not working. The first listbox was populated by a buttonclick in another form so there is nothing in it.
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Populating a listbox based on column of first listbox

    The example couldn't include the userform?

    Try something like this...
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    30

    Re: Populating a listbox based on column of first listbox

    Exactly what I needed. Thank you for your help! I have learned my lesson and next time will post it with the userform.

  6. #6
    Registered User
    Join Date
    01-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    30

    Re: Populating a listbox based on column of first listbox

    One last question: How would I make it so that the first listbox only showed column titles with 2 separate options in the column (Even if they were repeated)?

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Populating a listbox based on column of first listbox

    Quote Originally Posted by tucanj View Post
    One last question: How would I make it so that the first listbox only showed column titles with 2 separate options in the column (Even if they were repeated)?
    I don't follow? Two separate options?

  8. #8
    Registered User
    Join Date
    01-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    30

    Re: Populating a listbox based on column of first listbox

    So for example: column A contained cells 1: TitleA, 2: True, 3: True and 4: False. Column B contained cells 1: TitleB, 2: True, 3: False and 4: NA
    It would only show the TitleA in lisbox 1

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,464

    Re: Populating a listbox based on column of first listbox

    Try this
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    01-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    30

    Re: Populating a listbox based on column of first listbox

    Perhaps I am using it incorrectly but for me that populates VariableInterest with all columns instead of just those with two options, EDIT: but you are correct that does what I was looking for before. Thanks for your help!

+ 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