+ Reply to Thread
Results 1 to 8 of 8

Category mapping based on multiple criteria in multiple columns

  1. #1
    Registered User
    Join Date
    07-25-2008
    Location
    Irvine
    Posts
    7

    Category mapping based on multiple criteria in multiple columns

    I have a large amount of data with columns for Division, Department, and Account. I want to assign a category to every row of data based on complex criteria in those columns. Here are some examples:

    Category is "Absorption" if Division is not 000, Department is either 000 or in the range of 500-599, and Account is in the range of 60000-69999.

    Category is "Logistics" if Department is in the range of 700-799 and Account is in the range of 60000-69999 but is not 64600 or 64625.

    I can do this with multiple advanced filters but was wondering if there is a way to do this with formulas. Any help would be greatly appreciated!

  2. #2
    Registered User
    Join Date
    06-29-2011
    Location
    Fort Lauderdale
    MS-Off Ver
    Excel 2018
    Posts
    24

    Re: Category mapping based on multiple criteria in multiple columns

    What you provided is not so complex that it could not be done, if you add more Boolean rules then the formula can get rather large, but it's still possible. This code will work for what you described above so far. It assumes column B is the division, C is the department, and D is the Account; I'm assuming row 2 is the first check and I assume A2 is where this formula would go:

    Please Login or Register  to view this content.
    because the code above is a bit complex, I'll break it down into the 3 key sections below, but COPY the code above, this code below won't work if you try to paste it for use:

    IF( AND( B2<>0, OR(C2=0, AND( C2>=500, C2<=599 )), AND( D2>=60000, D2<=69999 )),"Absorption",
    IF( AND( AND( C2>=700, C2<=799 ), AND( D2>=60000, D2<>64600, D2<>64625, D2<=69999 )),"Logistics",
    "Other"))
    Last edited by theclockmaker; 01-27-2019 at 12:23 PM. Reason: forgot the OR statement that AliGW found

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2407 (Windows 11 23H2 64-bit)
    Posts
    82,903

    Re: Category mapping based on multiple criteria in multiple columns

    How is this bit going to work?

    IF( AND( B2<>0, C2=0, AND( C2>=500, C2<=599 )

    Why do you need the AND clause for C2 if it needs to equal zero?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Registered User
    Join Date
    07-25-2008
    Location
    Irvine
    Posts
    7

    Re: Category mapping based on multiple criteria in multiple columns

    Thanks theclockmaker, your formula works perfectly. However, it can be difficult to manage if I want to do this for 30 different categories and each of those categories have complex rules like that. I thought about using a UDF to lookup category names based on multiple criteria but couldn't find any good examples online.

  5. #5
    Registered User
    Join Date
    06-29-2011
    Location
    Fort Lauderdale
    MS-Off Ver
    Excel 2018
    Posts
    24

    Re: Category mapping based on multiple criteria in multiple columns

    I agree, VBA would be best then, it gives you more control and you can add comments.
    Something like this:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-29-2011
    Location
    Fort Lauderdale
    MS-Off Ver
    Excel 2018
    Posts
    24

    Re: Category mapping based on multiple criteria in multiple columns

    Quote Originally Posted by AliGW View Post
    How is this bit going to work?

    IF( AND( B2<>0, C2=0, AND( C2>=500, C2<=599 )

    Why do you need the AND clause for C2 if it needs to equal zero?
    Nice catch, I'll add edit my original post to include the OR operator as well. It should be C2=0 OR between 500-599

    IF( AND( B2<>0, OR(C2=0, AND( C2>=500, C2<=599 )), AND( D2>=60000, D2<=69999 )),"Absorption", ...

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2407 (Windows 11 23H2 64-bit)
    Posts
    82,903

    Re: Category mapping based on multiple criteria in multiple columns

    No problem!

  8. #8
    Registered User
    Join Date
    07-25-2008
    Location
    Irvine
    Posts
    7

    Re: Category mapping based on multiple criteria in multiple columns

    Thanks theclockmaker, I will use that macro and expand it for additional categories as needed.

+ 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. Complex Lookup based on Multiple Columns from Employee Mapping which is Horizontal
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-25-2018, 06:58 AM
  2. Replies: 1
    Last Post: 02-09-2017, 05:55 PM
  3. Average numbers from multiple columns based on multiple criteria
    By abambi in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-23-2015, 01:52 PM
  4. Populating fields in multiple cells based on criteria in multiple columns
    By excelalways in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-28-2014, 08:17 AM
  5. formulas for search based on multiple criteria in multiple columns
    By oneworld in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-02-2013, 06:57 AM
  6. [SOLVED] Deleting Duplicates Based on Multiple Criteria from Multiple Columns
    By Franklic in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-09-2012, 05:31 PM
  7. Macro to Segregate the data based on Multiple Criteria's in Multiple Columns -Challenging!
    By Novice_To_Excel in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-08-2012, 07:31 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