+ Reply to Thread
Results 1 to 13 of 13

Set a text value of a cell if a series of cells contains any specific text string

  1. #1
    Registered User
    Join Date
    09-17-2014
    Location
    Michigan
    MS-Off Ver
    Office 2010
    Posts
    7

    Set a text value of a cell if a series of cells contains any specific text string

    I've been able to piece together the following formula based on web searches, and I'm close to an answer.

    Here is what I want to do:
    An end cell has conditional formatting to color the cell red, green, or yellow when R, G, or Y respectively are in any of the preceding cells according to a heierarchy Where G trumps all, Y trumps, R, or blank if nothing. i.e. if all the previous cells in the row contain a Y then the end cell automatically populates a Y. But if any of the Cells contain a G then the last cell takes on a G value. Or if all are R except for 1 Y then the final cell populates as Y.

    =IF(ISNUMBER(SEARCH("G",N8)),"G",IF(ISNUMBER(SEARCH("Y",N8)),"Y",IF(ISNUMBER(SEARCH("R",N8)),"R"," ")))

    This works for a single cell N8. When I try to increase to a range to be N8:S8 The final cell in the row goes blank defaulting to my lowest level value.

    How do I get this formula to work with a series of cells instead of just a single cell?

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Set a text value of a cell if a series of cells contains any specific text string

    Can you post some sample scenarios and the results you want to see...based on those scenarios?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    09-17-2014
    Location
    Michigan
    MS-Off Ver
    Office 2010
    Posts
    7

    Re: Set a text value of a cell if a series of cells contains any specific text string

    Here are some more examples. S9 is the result field where I want the formula to auto populate. I don't care about doing a check that they only use G, Y, or R because I expect people to only use those value options. I just want it to behave as follows:
    Cell Example.JPG
    N8 O8 P8 Q8 R8 S8 T8
    Y Y Y Y G Y G (Because there is one G on the row)
    R R R R R R R (Because they are all R)
    R Y R R R R Y (Because there is one Y on the row)
    G G G G G G G (Because they are all G)
    R R G Y R R G (Because there is one G on the row)
    - - - - - - - (Blank because all fields are blank)

    The current formula I have does what I intend for the one cell I have in the formula. I can change to any letter and it behaves as I expect. I just can't figure out how to get it to behave that way using a series of cells in the row.

    The hierarchy is as follows: if there are any cells in row with G then the final cell will be G. If there is no G and any cells have Y then the final cell will be Y. If there is no G or Y then the final cell will be R, unless all cells contain no G's, Y's, or R's then the final cell is blank.
    Last edited by tubasparky; 09-17-2014 at 11:31 AM.

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Set a text value of a cell if a series of cells contains any specific text string

    This regular formula searches N8:S8 for an ordered list of letters (G,Y,R) and returns the highest scoring letter found
    Please Login or Register  to view this content.

    Is that something you can work with?

  5. #5
    Registered User
    Join Date
    09-17-2014
    Location
    Michigan
    MS-Off Ver
    Office 2010
    Posts
    7

    Re: Set a text value of a cell if a series of cells contains any specific text string

    I got a #VLUE! for that one. I don't understand where that formula is searching each cell for one of the 3 options. Can you explain that formula to me and maybe I'll see where it can work?

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Set a text value of a cell if a series of cells contains any specific text string

    I mistook your dashes in your example to mean blank cells.
    Try this formula
    Please Login or Register  to view this content.
    EDITED TO INCLUDE THIS BETTER ALTERNATIVE:
    Please Login or Register  to view this content.
    Does that help?
    Last edited by Ron Coderre; 09-17-2014 at 12:20 PM.

  7. #7
    Registered User
    Join Date
    09-17-2014
    Location
    Michigan
    MS-Off Ver
    Office 2010
    Posts
    7

    Re: Set a text value of a cell if a series of cells contains any specific text string

    It works better than mine for all the rows. But in the case where some cells are not filled in yet it defaults to the G which is the highest level answer. I would like it to default to the highest in the row even if some cells are blank. I guess I didn't include that scenario.
    For instance where "-" = blank cell

    N8 O8 P8 Q8 R8 S8 T8
    - - G Y R R G
    - - Y Y - - Y
    - - - - R R R

  8. #8
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Set a text value of a cell if a series of cells contains any specific text string

    NOTE: I tweaked these to remove some unnecessary pieces:
    I think this regular formula does what you want
    Please Login or Register  to view this content.
    or...if you're a fan of ARRAY FORMULAS, which are completed by holding down CTRL and SHIFT when you press ENTER (instead of just pressing ENTER), this slightly shorter formula.
    Please Login or Register  to view this content.
    (I just avoid them because nobody I work with ever remembers to C+S+E after editing them)

    Is that something you can work with?
    Last edited by Ron Coderre; 09-17-2014 at 01:13 PM.

  9. #9
    Registered User
    Join Date
    09-17-2014
    Location
    Michigan
    MS-Off Ver
    Office 2010
    Posts
    7

    Re: Set a text value of a cell if a series of cells contains any specific text string

    I only get blank in the last cell no matter what I put in the others. Will you help me to understand what that formula is supposed to be doing?

    BTW Ron, thank you for your help. I appreciate you working through this with me.

  10. #10
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Set a text value of a cell if a series of cells contains any specific text string

    Can you attach a sample workbook so I can see what you're working with?
    (I work at a major bank and can't send files out)

  11. #11
    Registered User
    Join Date
    09-17-2014
    Location
    Michigan
    MS-Off Ver
    Office 2010
    Posts
    7

    Re: Set a text value of a cell if a series of cells contains any specific text string

    Ron,

    Here is a sample of one row with the formatting. https://db.tt/qqPhSNa6
    I have my original formula in cell T8. So if you change the status of Cell N8 it will change the status of T8 and format accordingly. That is the way I would like it to function for all 6 cells simultaneously, with the hierarchy in place of G then Y then R, and blank if all cells are blank. There may be some cells which are N/A which should be ignored.

    Thanks for your help. I look forward to seeing what you come up with.

  12. #12
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Set a text value of a cell if a series of cells contains any specific text string

    Let's try this regular formula in your posted workbook
    Please Login or Register  to view this content.
    Does that help?

  13. #13
    Registered User
    Join Date
    09-17-2014
    Location
    Michigan
    MS-Off Ver
    Office 2010
    Posts
    7

    Re: Set a text value of a cell if a series of cells contains any specific text string

    Awesome!! That works great. Exactly what I was looking for! Thanks so much for your help Ron.

+ 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: 4
    Last Post: 07-21-2014, 10:33 AM
  2. [SOLVED] To search specific text in a cell that contains text string
    By mikail in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-15-2013, 03:02 PM
  3. Search a string for a specific text value from cells
    By hockeyadc in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-25-2013, 08:39 AM
  4. [SOLVED] Find partial text string within another text string return original text into cell.
    By mikey42979 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-17-2013, 02:58 PM
  5. [SOLVED] Macro to convert specific text and format specific text within a string
    By Mencae in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-06-2012, 12:13 AM

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