+ Reply to Thread
Results 1 to 4 of 4

I need something like SUMIF that can return a string

Hybrid View

  1. #1
    Registered User
    Join Date
    10-23-2017
    Location
    Boston, MA
    MS-Off Ver
    Excel 365
    Posts
    73

    I need something like SUMIF that can return a string

    Suppose I have A1:A5, which contain the words "red", "blue", "green", "yellow", and "orange"
    In B1:B5, I have 1, 1, 1, 0, and 1, and these values are each set by several steps of formulas where they can only be 1 or 0, and exactly 1 cell in the row is always equal to 0. In C1, I want to get the word in A1:A5 that corresponds with the 0 in B1:B5. So in this case, it would find that B4=0, and then return the contents of A4, which is "yellow".

    I tried doing this with C1=SUMIF(B1:B5,0,A1:A5), but this does not work. I have a feeling I'm making this a lot harder than it should be, and SUMIF probably isn't even the right function for this.

    A somewhat related question (about SUMIF)... can you use a row for the criteria range and a column for the sum range (assuming it's the same total number of cells)?

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: I need something like SUMIF that can return a string

    Give this a try

    =INDEX(A1:A5,MATCH(0,B1:B5,0))

    For your question #2, need to see your data in a workbook.
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    10-23-2017
    Location
    Boston, MA
    MS-Off Ver
    Excel 365
    Posts
    73

    Re: I need something like SUMIF that can return a string

    For question #2, let me start over. I'm probably asking the wrong question based on faulty assumptions about the correct way to pursue this.

    Here's an example where I have colors again, and each color relates to each other color in some way represented by a number (it's meaningless, I just made these up to create an example). What I want to do is, if I know the name of the two colors, I want to be able to get the value from this table where the intersection is (assuming that one color is known to be in the row and the other color is known to be in the column). So if I have a cell B8="red" and I know this means the color along the row B1:F1, and C8="blue and I know this refers to the column A2:A6, I have a cell E8=(some formula) that somehow ends up displaying a value of 1.241.
    Attached Images Attached Images

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,426

    Re: I need something like SUMIF that can return a string

    You can use this formula:

    =INDEX($B$2:$F$6,MATCH(C8,$A$2:$A$6,0),MATCH(B8,$B$1:$F$1,0))

    when the index range covers two dimensions, the syntax is:

    INDEX(table,row,column)

    Hope this helps.

    Pete

+ 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: 6
    Last Post: 09-05-2019, 07:45 AM
  2. Script to Search for a specific String then return cell values above that String-4
    By owensjb2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-03-2015, 01:28 AM
  3. [SOLVED] Script to Search for a specific String then return cell values above that String-3
    By owensjb2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-01-2015, 01:50 PM
  4. [SOLVED] Script to Search for a specific String then return cell values above that String-2
    By owensjb2 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-01-2015, 01:00 PM
  5. [SOLVED] Script to Search for a specific String then return cell values above that String
    By owensjb2 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-01-2015, 11:28 AM
  6. Replies: 4
    Last Post: 03-30-2015, 03:20 PM
  7. [SOLVED] IF range of cells contains string of text, return contents of cell where string is found
    By nobodyukno in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-03-2013, 09:56 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