+ Reply to Thread
Results 1 to 16 of 16

IF-formula with several true values?

  1. #1
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    153

    IF-formula with several true values?

    I have a cell where the data can change between a number of different letter combinations. I know what combinations the cell might contain. SOME of these combinations should not be shown, if that particular combination would occur.

    So I need an IF-formula for creating a new cell that says something like:

    "IF the cell I'm thinking of contains AA or Aa or Bb or sgsg or dsds or Bb or BB, this cell should say "". If it contains anything else than the previous stated combinations, it should just copy the previous cell as it is."

    I can fill in the AA's and Aa's and everything in the formula by myself (there are more combinations than the ones I wrote here), but I don't know how I add more true values to the formula than one.

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,755

    Re: IF-formula with several true values?

    do they need to be case sensitive

    =IF( OR( Cell="AA", cell="BB", cell="sgsg", etc ), true , false)

    if you need case sensitve use EXACT

    =IF( OR( EXACT(Cell,"AA"), EXACT(cell,"BB"), EXACT(cell,"sgsg"), etc ), true , false)

    to get
    this cell should say "". If it contains anything else than the previous stated combinations, it should just copy the previous cell as it is."
    the true / false

    replace with

    "", cell)
    Last edited by etaf; 06-16-2013 at 04:39 PM.

  3. #3
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    153

    Re: IF-formula with several true values?

    I do need them case sensitive, but when I tried to enter the formula, I got an error. Did I do something wrong? This is what I tried to write:

    =IF( OR( EXACT(AG4,"AA"), EXACT(AG4,"BB"), EXACT(AG4,"sgsg") ), "" , AG4)

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: IF-formula with several true values?

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    works fine for me
    maybe you need; instead of ,
    =IF(OR(EXACT(AG4;"AA");EXACT(AG4;"BB"),EXACT(AG4;"sgsg") );"";AG4)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: IF-formula with several true values?

    Enter all the combinations in a range, ie A2:A20, then;

    =IF(SUMPRODUCT(EXACT(AG4,A2:A20)+0),"",AG4)
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: IF-formula with several true values?

    Here's another one...

    List all of the combinations in a range of cells, say A2:A5.

    Then, this array formula**:

    =IF(COUNT(FIND(A2:A5,AG4)),"",AG4)

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  7. #7
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    153

    Re: IF-formula with several true values?

    Thank you, Tony! That sounds like a perfect way of doing it! Though, nothing happens when I hit Ctrl, Shift, Enter. Am I doing something wrong? I just choose a cell, then hit Ctrl, Shift, Enter. I kind of expected something to pop up, but nothing did.

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: IF-formula with several true values?

    Did you actually enter the formula in a cell?

    Select the cell where you want the formula.

    Type the formula but don't hit the enter key like you normally would. Use the key combination of CTRL, SHIFT, ENTER.

    Array formulas are entered differently than a regular formula.
    After you type in a regular formula you hit the ENTER key.
    With an array formula you *must* use a combination of keys.
    Those keys are the CTRL key, the SHIFT key and the ENTER key.
    That is, hold down both the CTRL key and the SHIFT key then
    hit the ENTER key.

    When done properly Excel will enclose the formula in squiggly
    brackets { }. You can't just type these brackets in, you
    *must* use the key combo to produce them. Also, anytime
    you edit an array formula it *must* be re-entered as an
    array using the key combo.

    Or, maybe the formula is returning a blank? My understanding is that when cell AG4 contains one of the matching entries the formula should return a blank.

  9. #9
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    153

    Re: IF-formula with several true values?

    Ooooh, I've misunderstood the whole thing! I hit the combination BEFORE I entered the formula into the cell. I didn't understand that you had to do the combination afterwards!

    Though, it still doesn't work. It gives me an error sign every time I try to replace the end of the formula: A2:A5,AG4)),"",AG4) with the correct cells.

    Here's a workbook with an example of my data:

    Workbook genes expressed.xlsx

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: IF-formula with several true values?

    Ok, it looks like the letter combinations are in the range A2:A28.

    So what cell(s) do you want to compare those combinations to? Where do you want the formula results to appear? It would be better if you could show us what results you expect. If you've already done that in the sample file then I am completely lost!

  11. #11
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    153

    Re: IF-formula with several true values?

    I've given one example in the workbook of how I want the result to be:
    __________
    Only the genes that will be expressed:
    SgsgUu
    __________

    The code SgsgUu is what should come out after the formula has done it's job.

    Basically, I need it to merge J2 through P2, but only add the cells that are not listed in the "Genes that will not be expressed"-column.

    So if one cell under "Gene code result" contains, for example, Pp, it should not be merged. If it contains anything other than what's in the "Genes that will not be expressed"-column, it SHOULD be merged.

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: IF-formula with several true values?

    OK, I think I understand.

    Hmmm...

    Well, none of the formulas we suggested so far will do what you want.

    You can either use a very long formula made up of a bunch of concatenated IF functions...

    Array entered**:

    =IF(OR(EXACT(A$2:A$28,J2)),"",J2)&IF(OR(EXACT(A$2:A$28,K2)),"",K2)&IF(OR(EXACT(A$2:A$28,L2)),"",L2)&IF(OR(EXACT(A$2:A$28,M2)),"",M2)&IF(OR(EXACT(A$2:A$28,N2)),"",N2)&IF(OR(EXACT(A$2:A$28,O2)),"",O2)&IF(OR(EXACT(A$2:A$28,P2)),"",P2)

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Or, you could use a VBA concatenation function like the one here:

    http://www.excelforum.com/tips-and-t...geravatar.html

    If you want to use the VBA function let me know.
    Last edited by Tony Valko; 06-17-2013 at 10:53 AM. Reason: I don't know how to spell

  13. #13
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    153

    Re: IF-formula with several true values?

    I can't use macros, since other people need to be able to access this document and just fill in a couple of cells and then the result should appear instantly.

    But when I try to enter the array formula (into R2) and hit Ctrl, Shift and Enter - nothing happens. No brackets appear around the formula or anything.

  14. #14
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: IF-formula with several true values?

    Here's the file with the formula entered.

    Workbook genes expressed(1).xlsx

  15. #15
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    153

    Re: IF-formula with several true values?

    Thank you! It seems to be exactly what I wanted!

    Thank you soooo much! :D

  16. #16
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: IF-formula with several true values?

    You're welcome. Thanks for the feedback!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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