+ Reply to Thread
Results 1 to 6 of 6

Listbox based on a criteria

  1. #1
    Forum Contributor stephenloky's Avatar
    Join Date
    07-10-2013
    Location
    Sao Paulo - Brazil
    MS-Off Ver
    Excel 2007
    Posts
    146

    Listbox based on a criteria

    Hello everyone, I have a table1 (see attch.) and a "form" to someone to fill.
    Then I want to fill the "account" and based on the account choosed I display certain values to field "Value". I'm planning making this on VBA but im not with a clear mind on how doing this...could please someone help me out?
    If you have any doubts regarding the excel file, please tell me and I will post the answer ASAP.
    Thanks all!
    example1.xlsx
    "The quieter you become, the more you are able to hear"

    Any reputation (*) points appreciated.

    "If you know yourself but not the enemy, for every victory gained, you will suffer defeat."

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Listbox based on a criteria

    sounds like you are after dependant DV?

    http://www.contextures.com/xlDataVal02.html
    Attached Files Attached Files
    Last edited by humdingaling; 07-04-2014 at 03:25 AM.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Contributor stephenloky's Avatar
    Join Date
    07-10-2013
    Location
    Sao Paulo - Brazil
    MS-Off Ver
    Excel 2007
    Posts
    146

    Re: Listbox based on a criteria

    Quote Originally Posted by humdingaling View Post
    sounds like you are after dependant DV?

    http://www.contextures.com/xlDataVal02.html
    That's exactly what I need, but, I want something more dinamic, for example, If I a add a new "account", the named range will be automatically resized....can I resize name-range in VBA??
    And thanks for the answer, I really appreciate it!!! * Only if it's simple, if it's not, just leave the problem..hehe, dont need to burn your brain.
    Last edited by stephenloky; 07-04-2014 at 09:01 AM.

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Listbox based on a criteria

    it can be done, a little more complicated but not much

    put comments into the spreadsheet so hope you understand what i have done

    basically named range "Accounts" now increases/decreases according to the COUNTA in column L...up to 100...extend if you need more..decrease if you don't want so long

    table 1 needs to be updated to match subsequent additions in accounts
    Attached Files Attached Files

  5. #5
    Forum Contributor stephenloky's Avatar
    Join Date
    07-10-2013
    Location
    Sao Paulo - Brazil
    MS-Off Ver
    Excel 2007
    Posts
    146

    Re: Listbox based on a criteria

    Quote Originally Posted by humdingaling View Post
    it can be done, a little more complicated but not much

    put comments into the spreadsheet so hope you understand what i have done

    basically named range "Accounts" now increases/decreases according to the COUNTA in column L...up to 100...extend if you need more..decrease if you don't want so long

    table 1 needs to be updated to match subsequent additions in accounts
    Thanks for you answer!
    I have one question,
    I've added 'QQ' to the table1 and a value to it, shouldn't in the Value of the Expected output if i selected 'QQ' should appear the value if put on table1? nothing is happening...sorry if i misunderstood.

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Listbox based on a criteria

    Sorry forgot to add offset named range which would automatically add the DV

    the formula behind it is
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    its a bit scary to begin with but breaks down rather easily

    basically
    from B3 (start of your table)
    find the first matching account (then minus 1)
    offset to the right 1 column
    then the countif counts how long you want the DV to be...which is the number of accounts

    adjust the match length and Countif length array if its too long or short

    now....you must sort the table to have all the same accounts in a row
    its quite clear in the example i have highlighted
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Creating a Range of a Listbox based on the Selection Made in Another ListBox
    By masood78 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-02-2014, 11:03 AM
  2. Filling a listbox with unique entries in a row based on certain criteria
    By grzzzly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-07-2013, 05:16 AM
  3. Replies: 12
    Last Post: 08-28-2012, 07:09 AM
  4. Populating listbox based on two (or more) criteria
    By jasonsweeney in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-04-2006, 07:44 PM
  5. ListBox Add Item based on criteria
    By James W. in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2005, 05:06 PM

Tags for this Thread

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