+ Reply to Thread
Results 1 to 17 of 17

Create unique list of values from two ranges with criteria

  1. #1
    Forum Contributor
    Join Date
    01-25-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    434

    Create unique list of values from two ranges with criteria

    I have two lists of values in separate columns with condition in adjacent cells, all on the same sheet

    List 1 consists of numbers from 1 to 12, column to the right is either blank or Free
    List 2 consists of numbers from 13 to 24, column to the right is either blank of Free

    List 1 starts in A2, B2 is either blank or Free
    List 2 starts in D2, E2 is either blank or Free

    In column G, from G2 i want it to list all values from List 1 and List 2 where their status is Free

    attached file has the complete example

    thanks in advance of any assistance

  2. #2
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Create unique list of values from two ranges with criteria

    Here are two ways you can do it.
    1. Include a sample workbook with an example of the result you want
    2. Use [CODE] and [FORMULA] wrappers for your VBA code or excel formulas
    3. If your question has been answered, mark the thread as SOLVED and click on the "Add Rep" star to thank whoever helped you.

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Create unique list of values from two ranges with criteria

    Try this...

    Data Range
    A
    B
    C
    D
    E
    F
    G
    1
    List1
    Status
    List2
    Status
    Expected Output
    2
    1
    Free
    13
    1
    3
    2
    14
    Free
    3
    4
    3
    Free
    15
    6
    5
    4
    16
    7
    6
    5
    17
    9
    7
    6
    Free
    18
    Free
    10
    8
    7
    Free
    19
    Free
    14
    9
    8
    20
    Free
    18
    10
    9
    Free
    21
    Free
    19
    11
    10
    Free
    22
    20
    12
    11
    23
    21
    13
    12
    24
    Free
    24
    14
    ------
    ------
    ------
    ------
    ------
    ------
    ------


    This array formula** entered in G2:

    =IFERROR(INDEX(A:A,SMALL(IF(B$2:B$13="Free",ROW(B$2:B$13)),ROWS(I$2:I2))),IFERROR(INDEX(D:D,SMALL(IF(E$2:E$13="Free",ROW(E$2:E$13)),ROWS(I$2:I2)-COUNTIF(B$2:B$13,"Free"))),""))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Copy down until you get blanks.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Forum Contributor
    Join Date
    01-25-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    434

    Re: Create unique list of values from two ranges with criteria

    Hi k64

    I like what you did in A27 : D27
    shame it didn't cope with multiple ranges in the same formula, but as values 1-12 and 13-24 are fixed, I can just use a helper column to replicate what you did

    when i was researching this type of problem, I could find one close enough to my scenario, they were either too simple or too complex, no goldielocks

    many thanks

    32

  5. #5
    Forum Contributor
    Join Date
    01-25-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    434

    Re: Create unique list of values from two ranges with criteria

    Tony Tony Tony

    that is ace ace ace

    all in one solution, excellent

    @k64 - thanks for your solution, but going with Tony's, hopefully we can both learn something by seeing how Tony worked it out
    so high fives all round

    @tony - use of column I for row number, guess it won't matter if this is changed to any other column ?

    thanks again all, marked as solved and rep awarded

    32

  6. #6
    Forum Contributor
    Join Date
    01-25-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    434

    Re: Create unique list of values from two ranges with criteria

    @k64 - "You must spread some Reputation around before giving it to k64 again."

    sorry couldn't add rep

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Create unique list of values from two ranges with criteria

    Quote Originally Posted by ThirtyTwo View Post

    @tony - use of column I for row number, guess it won't matter if this is changed to any other column ?
    Typically, you want to use the cell address of the first cell the formula is entered in.

    I wrote the formula in column I to compare the results with your expected results then I just moved it over to column G and forgot to change the ROWS(...) references.

  8. #8
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Create unique list of values from two ranges with criteria

    Oh, yeah. Tony's formula is basically my formula with IFERRORs. I don't know why I didn't think of that! I used IFERRORs to solve the range problem in my first attempt. Guess I just didn't put 2 and 2 together.
    That's okay. Maybe sometime later after you've been helped by other people. Thanks

  9. #9
    Forum Contributor
    Join Date
    01-25-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    434

    Re: Create unique list of values from two ranges with criteria

    I made an error made by many other users of the forum

    I thought by making the example as basic as possible I'd be able to make modifications later to suit exact requirements

    when i added headers and such, I couldn't make the necessary adjustments for it to work

    List 1 is fine, it just doesn't give any results from List 2

    List 1 now starts in column B
    List 2 now starts in column F

    condition for List 1 is in column D
    condition for List 2 is in column H

    row now starts on 7 rather than 2 as in the initial example

  10. #10
    Forum Contributor
    Join Date
    01-25-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    434

    Re: Create unique list of values from two ranges with criteria

    nm

    Please Login or Register  to view this content.
    i had a couple of problems, i was starting the formula on row 6 rather than 7 and also checking for Complete rather than Free

    all's good again

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Create unique list of values from two ranges with criteria

    Quote Originally Posted by ThirtyTwo View Post
    nm

    =IFERROR(INDEX(B:B,SMALL(IF(D$7:D$18="Free",ROW(B$7:B$18)),ROWS(J$7:J7))),IFERROR(INDEX(F:F,SMALL(IF(H$7:H$18="Free",ROW(H$7:H$18)),ROWS(J$7:J7)-COUNTIF(H$7:H$18,"Free"))),""))
    The COUNTIF should refer to the 1st list. Based on the formula it should be:

    COUNTIF(D$7:D$18,"Free")

  12. #12
    Forum Contributor
    Join Date
    01-25-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    434

    Re: Create unique list of values from two ranges with criteria

    is it possible to do something like

    Please Login or Register  to view this content.
    to test if it's blank or is Free

  13. #13
    Forum Contributor
    Join Date
    01-25-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    434

    Re: Create unique list of values from two ranges with criteria

    going back to the original layout

    the {"Free",""}
    works for List 1

    but it misses out rows 2 to 6 for List 2

    Please Login or Register  to view this content.

  14. #14
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Create unique list of values from two ranges with criteria

    Can you post another file that shows your expected results?

  15. #15
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Create unique list of values from two ranges with criteria

    OK, for this specific application just change the COUNTIF to:

    SUM(COUNTIF(B$2:B$13,{"Free",""}))

    However, that just combines all of both lists into a single list. If you just want to combine both lists without conditions it's a bit easier:

    =IFERROR(IF(ROWS(G$2:G2)>ROWS(A$2:A$13),INDEX(D$2:D$13,ROWS(G$2:G2)-ROWS(A$2:A$13)),INDEX(A$2:A$13,ROWS(G$2:G2))),"")

  16. #16
    Forum Contributor
    Join Date
    01-25-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    434

    Re: Create unique list of values from two ranges with criteria

    excellent

    thanks again

    32

  17. #17
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Create unique list of values from two ranges with criteria

    You're welcome. Thanks for the feedback!

+ 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. [SOLVED] Looking to create a list of unique names that match criteria without using an array
    By john dalton in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 03-28-2014, 04:28 AM
  2. [SOLVED] Create a list of unique entries that did not meet a specific criteria
    By joannelittell in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-23-2013, 12:08 PM
  3. [SOLVED] Create list based on criteria and is unique
    By joannelittell in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 10-13-2013, 02:33 PM
  4. [SOLVED] Create unique list based on specific criteria
    By Joynesy in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-21-2013, 05:54 AM
  5. Create Unique List with Criteria
    By Fos605 in forum Excel General
    Replies: 2
    Last Post: 07-20-2010, 07:57 AM

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