+ Reply to Thread
Results 1 to 5 of 5

Searching a column for a value and returning a list of corresponding values

  1. #1
    Registered User
    Join Date
    08-10-2011
    Location
    canada
    MS-Off Ver
    Excel 2003
    Posts
    17

    Searching a column for a value and returning a list of corresponding values

    Hi there,

    Here is an example to demonstrate what I would like to do:

    Say I have 2 columns -

    column 1----column 2
    ---a------------1----
    ---b------------2----
    ---b------------3----
    ---b------------4----
    ---a------------5----
    ---b------------6----
    ---a------------7----
    ---b------------8----

    Is there a way I can make a new column that searches for all the a's and returns the corresponding column 2 values to the top of the new column and working down. So the final column would look like this:

    column 3
    ----1----
    ----5----
    ----7----

    Thanks!
    Last edited by sarman; 08-15-2011 at 05:58 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Searching a column for a value and returning a list of corresponding values

    Try this.

    D1: a
    D2: =COUNTIF(A:A,D1)
    F1: =IF(ROWS($A$1:$A1)>$D$2, "", INDEX($B$1:$B$100, SMALL(IF($A$1:$A$100=$D$1, ROW($A$1:$A$100), ""), ROWS($A$1:$A1))))
    ...confirmed by pressing Ctrl-Shift-Enter to activate the array formula

    The first answer of 1 should appear.

    Copy F1 and paste in F2:F20.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-10-2011
    Location
    canada
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Searching a column for a value and returning a list of corresponding values

    Thanks, works great!

  4. #4
    Registered User
    Join Date
    08-10-2011
    Location
    canada
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Searching a column for a value and returning a list of corresponding values

    Say I had the same column 1 and column 2 on multiple sheets, is there a way to search through all of the sheets?

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Searching a column for a value and returning a list of corresponding values

    Not simply, no. Putting all the values on a single sheet would let you continue to use this array formula approach.

    If you move to a VBA programming approach, then you could search as many sheets as you wish to compile a summary list on a specific sheet.

+ 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