+ Reply to Thread
Results 1 to 6 of 6

IF function to return text if a cell = another range of cells

  1. #1
    Registered User
    Join Date
    10-17-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    4

    IF function to return text if a cell = another range of cells

    Is it possible to write a formula to return certain words if a cell is equal to other ranges?

    For example, I am writing a Bill of materials and I need column G to say "metres", "Each", or "Pair" depending on the hardware used. That info comes from another sheet in the workbook (Master).

    The formula I have written works for simple one cell equals another cell, but if cell Master!C118 equals a cell in the described ranges I get a #VALUE! error.

    Please Login or Register  to view this content.
    Any help would be appreciated.

  2. #2
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: IF function to return text if a cell = another range of cells

    Instead of using nested IF statements, you could create a lookup table and use VLOOKUP or INDEX/MATCH to return the values. This makes your formula scalable, and negates you having to manually go in and change every word in quotations manually. If you can upload a sample workbook, more detailed help can be given.
    Spread the love, add to the Rep

    "None of us are as smart as all of us."

  3. #3
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: IF function to return text if a cell = another range of cells

    Hi.

    I think you mean:

    =IF(Master!C118="None","",IF(Master!C118=Master!B415,"Pair",IF(COUNTIF(Master!B418:Master!B446,Master!C118),"Each",IF(COUNTIF(Master!B450:Master!B454,Master!C118),"Metre",""))))

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: IF function to return text if a cell = another range of cells

    It doesn't mean anything for a single cell to be equal to a range of cells. What do you mean there? Do you mean if C118 is equal to any cell in the range B418:B446? If so, one way to do it would be:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

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

    Re: IF function to return text if a cell = another range of cells

    It would be easier to use a VLOOPUP formula in conjunction with a small table. I don't know what is contained in cells B415, B418:B446, or B450:B454 on the Master sheet as you didn't attach a workbook, but if you copy those cells to (for example) X1, X2 etc. and put the corresponding "Pair", "Each", "Meter" in column Y against each cell, then you could have this formula:

    =IF(Master!C118="None","",IFERROR(VLOOKUP(Master!C118,Master!$X:$Y,2,0),""))

    Hope this helps.

    Pete

  6. #6
    Registered User
    Join Date
    10-17-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: IF function to return text if a cell = another range of cells

    SOLVED

    Thank you all for the quick answers.

    I plugged in both suggestions from 6StringJazzer and XOR LX, and they both worked.

    I hadn't thought about a VLOOKUP table, I will try that as well when I have more time, this is a work in progress!
    I have updated everyones rating.

+ 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: 2
    Last Post: 09-07-2013, 07:50 PM
  2. search a range of cells for text and return that text
    By strucad in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-05-2013, 03:45 AM
  3. [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
  4. [SOLVED] Return specific text if a different text is contained anywhere in a range of cells
    By ciayers in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-06-2013, 05:54 PM
  5. Replies: 4
    Last Post: 07-29-2012, 08:54 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