+ Reply to Thread
Results 1 to 7 of 7

Assign Yes/No to Cell Based on Meeting Some Criteria

  1. #1
    Registered User
    Join Date
    12-04-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2013
    Posts
    41

    Assign Yes/No to Cell Based on Meeting Some Criteria

    Hi,

    I need to write an excel function/macro/code to assign yes or no to a cell if the Description fits a certain category. I have attached a sample workbook and will explain what I mean.

    In the sample workbook, there is data on a company. This included a unique ID, city, state, and description. What I want to do is fill out the yes/no column. So if a particular company has 2 of the 4 necessary "Descriptions", then column G will return yes, otherwise No. It must return yes for a particular company/ID if 2 of the "Descriptions" are "Sale", "Service", "Business", or "Par". I only want it to count at least two unique descriptions.

    For example, in the sample workbook, Company A has all 4 of the necessary descriptions, thus everything in column G for this specific client should be yes. For Company B, only 1 of the 4 descriptions matches, so it returns No for all Company 2 columns. Company C has 2 of 4, so it returns yes for these columns. Note, it doesn't matter for Company C that "Business" was listed twice. It only needs to count the first unique time that description occurs.

    Any suggestions on how to approach this?

    Thanks.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: Assign Yes/No to Cell Based on Meeting Some Criteria

    In G2, enter the formula

    =IF((COUNTIFS(B:B,B2,C:C,C2,D:D,D2,F:F,"Sale")>0)*1+(COUNTIFS(B:B,B2,C:C,C2,D:D,D2,F:F,"Service")>0)*1+(COUNTIFS(B:B,B2,C:C,C2,D:D,D2,F:F,"Business")>0)*1+(COUNTIFS(B:B,B2,C:C,C2,D:D,D2,F:F,"Par")>0)*1>=2,"Yes","No")

    I wrote this such that if company A has two branches, in different city and/or state that those will not be used. If that is not the case, COUNTIFS(B:B,B2,C:C,C2,D:D,D2,F:F can be shortened to COUNTIFS(B:B,B2,F:F in all four instances
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Assign Yes/No to Cell Based on Meeting Some Criteria

    Hi,

    In G2 copied down

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: Assign Yes/No to Cell Based on Meeting Some Criteria

    Richard,

    That will not meet the requirement: "only needs to count the first unique time that description occurs", and it is also possible that there are other descriptions beyond the five examples that should also be ignored.

  5. #5
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Assign Yes/No to Cell Based on Meeting Some Criteria

    with an pivot table ?

    see the attached file.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  6. #6
    Registered User
    Join Date
    12-04-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2013
    Posts
    41

    Re: Assign Yes/No to Cell Based on Meeting Some Criteria

    Thanks, the formula worked well. I have a secondary question. What if I wanted to change it such that, one of the 4 was absolutely required while the last one could come from the other three. So for example, let's say it should count yes only if it has some combination of 2 of the 4 items needed, but one of the two items needed has to be "Business". How could I adjust that?

  7. #7
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: Assign Yes/No to Cell Based on Meeting Some Criteria

    Just use the Business part as the first conditional:

    =IF(COUNTIFS(B:B,B2,C:C,C2,D:D,D2,F:F,"Business")>0, IF((COUNTIFS(B:B,B2,C:C,C2,D:D,D2,F:F,"Service")>0)*1+(COUNTIFS(B:B,B2,C:C,C2,D:D,D2,F:F,"Sale")>0)*1+(COUNTIFS(B:B,B2,C:C,C2,D:D,D2,F:F,"Par")>0)*1>=1,"Yes","No"),"No")

+ 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: 9
    Last Post: 12-22-2013, 09:29 PM
  2. Totals based on meeting multiple criteria
    By JerryS in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-08-2006, 05:40 PM
  3. Show top five records based on meeting multiple criteria
    By Joe D in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-20-2005, 07:55 PM
  4. Top Five selections based on sum of items meeting criteria
    By Joe D in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-20-2005, 07:50 PM
  5. calculation based on meeting two criteria
    By jerry in forum Excel General
    Replies: 2
    Last Post: 10-06-2005, 08:05 PM

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