+ Reply to Thread
Results 1 to 7 of 7

Generate a list of products based on what category it's assigned to

  1. #1
    Registered User
    Join Date
    09-21-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Question Generate a list of products based on what category it's assigned to

    I have a list of products with a column indicating what category it's in. Is there a formulaic way for me to generate a list of all the products in a given category?


    A B
    1 PRODUCT CATEGORY
    2 Cookies Snacks
    3 Pretzels Snacks
    4 Carrots Snacks
    5 Apples Snacks
    6 Water Drinks
    7 Soda Drinks
    8 Juice Drinks
    9 Milkshake Drinks

    How could I make a list in a single column that shows me only the Drinks, for example?

  2. #2
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,292

    Re: Generate a list of products based on what category it's assigned to

    Try a pivot table
    Attached Files Attached Files
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  3. #3
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Generate a list of products based on what category it's assigned to

    Enter formula in C2 and copy across and down
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    v A B C D
    1 PRODUCT CATEGORY Snacks Drinks
    2 Cookies Snacks Cookies Water
    3 Pretzels Snacks Pretzels Soda
    4 Carrots Snacks Carrots Juice
    5 Apples Snacks Apples Milkshake
    6 Water Drinks
    7 Soda Drinks
    8 Juice Drinks
    9 Milkshake Drinks
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

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

    Re: Generate a list of products based on what category it's assigned to

    One way...

    Data Range
    A
    B
    C
    D
    E
    1
    PRODUCT
    CATEGORY
    ------
    CATEGORY
    PRODUCT
    2
    Cookies
    Snacks
    Drinks
    Water
    3
    Pretzels
    Snacks
    Soda
    4
    Carrots
    Snacks
    Juice
    5
    Apples
    Snacks
    Milkshake
    6
    Water
    Drinks
    7
    Soda
    Drinks
    8
    Juice
    Drinks
    9
    Milkshake
    Drinks


    This formula entered in E2:

    =IF(ROWS(E$2:E2)>COUNTIF(B:B,D$2),"",INDEX(A:A,MATCH(D$2,B:B,0)+ROWS(E$2:E2)-1))

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

    Let's Go Pens. We Want The Cup.

  5. #5
    Registered User
    Join Date
    09-21-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Generate a list of products based on what category it's assigned to

    This formula entered in E2:

    =IF(ROWS(E$2:E2)>COUNTIF(B:B,D$2),"",INDEX(A:A,MATCH(D$2,B:B,0)+ROWS(E$2:E2)-1))

    Copy down until you get blanks.

    This solution worked, but I'm not really sure HOW it works. No pressure, but if you could explain the elements of it (why the row and countif functions are used, for example and what they're doing in the formula). I simplified my actual problem, so trying to scale this to fit what I actually need requires that I understand it completely.

  6. #6
    Registered User
    Join Date
    09-21-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Generate a list of products based on what category it's assigned to

    Quote Originally Posted by popipipo View Post
    Try a pivot table
    Unfortunately, I need it to work with formulas. Thanks, though!
    Last edited by kitpierce; 07-14-2016 at 03:56 PM. Reason: added quote

  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: Generate a list of products based on what category it's assigned to

    Quote Originally Posted by kitpierce View Post
    if you could explain the elements of it (why the row and countif functions are used, for example and what they're doing in the formula).
    =IF(ROWS(E$2:E2)>COUNTIF(B:B,D$2),"",INDEX(A:A,MATCH(D$2,B:B,0)+ROWS(E$2:E2)-1))

    This portion is an error trap:

    =IF(ROWS(E$2:E2)>COUNTIF(B:B,D$2),"",

    It counts the number of cells the formula is copied to compared to the count of drinks. If/when the number of cells is greater than the count then the formula returns a blank which means all the relevant data has been extracted.

+ 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. Replies: 1
    Last Post: 05-12-2016, 09:29 AM
  2. [SOLVED] VBA to to create a list of product variations based on list of parent products
    By irruzzz in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-12-2016, 08:27 AM
  3. Automatic Generate Numbers based on already assigned letters
    By sunil31 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 12-01-2015, 07:48 AM
  4. Automatic Generate Numbers based on already assigned letters
    By sunil31 in forum Excel Formulas & Functions
    Replies: 23
    Last Post: 11-28-2015, 11:44 PM
  5. Inputed Transactions Get Assigned to Category
    By spurredhal in forum Excel General
    Replies: 5
    Last Post: 03-10-2013, 01:49 PM
  6. How to add up products across a row based on a price list?
    By JonathanSQ in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-21-2008, 01:30 PM
  7. how to generate report based on adding costs of particular category
    By hoser in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 12-20-2007, 06:58 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