Results 1 to 5 of 5

Thread: Contains

  1. #1
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm sure this has come up before, but have had no success in finding it.

    Anyway, all I want to do is get a T or F if a cell contains a specified value.

    PS I'm using 2007 SP1

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    [quote name='Egg 'n' Bacon' post='779496' date='12-Jun-2009 05:15']Anyway, all I want to do is get a T or F if a cell contains a specified value.[/quote]

    If we presume that A1 is the cell and the specified value is 5 then you can have a formula in a cell:
    =if(a1=5,"T","F")

    If you want the cell itself to display a T or F depending on the value (again presuming it is 5) you can use a custom format [Format - Cells - Number(tab) - Category: Custom]
    [=5]"T";"F"


    Steve

  3. #3
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry, I was lazy explaining.

    I want the formula to return 'True' or 'False' depending wether the reference cell contains a specified value;

    e.g. value of A1 = U and M

    A2 = if(A1,contains " and ", "True", "False")

    Hope that makes more sense

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You could use

    =NOT(ISERROR(SEARCH(" and ",A1)))

    to return TRUE or FALSE as Boolean values. If you really need to return text strings, use

    =IF(ISERROR(SEARCH(" and ",A1)),"False","True")

  5. #5
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you. That's what I needed.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •