+ Reply to Thread
Results 1 to 4 of 4

Can I use "In" in an "If" statement?

  1. #1
    mbrockhaus
    Guest

    Can I use "In" in an "If" statement?

    I want to determine if a value in column A is in a list of values, using an
    if statement. Do I need to list each condition separately? For example, is
    there a better way to write the following statement?

    =IF(OR($A2<>"Benchmark",$A2<>"Benchmark Folder",$A2<>"Physical
    Name",$A2="Label Part"), "y", "n")

  2. #2
    Forum Contributor
    Join Date
    06-01-2006
    Posts
    324
    You can save 4 characters by doing this...

    =IF(OR($A2="benchmark",$A2="benchmark folder",$A2="physical name",$A2="label part"), "n", "y")

    it doesn't check for case, so you don't have to cap the first letter...

    The other thing you can do is make a table of what you are checking, I put it in L1:L4

    =IF(ISERROR(MATCH(A2,L1:L4)), "y", "n")
    Google is your best friend!

  3. #3
    Dave Peterson
    Guest

    Re: Can I use "In" in an "If" statement?

    I would think you'd want an exact match:
    =IF(ISERROR(MATCH(A2,L1:L4,0)), "y", "n")

    or alternatively:
    =IF(ISnumber(MATCH(A2,L1:L4,0)), "n", "y")




    Bearacade wrote:
    >
    > You can save 4 characters by doing this...
    >
    > =IF(OR($A2="benchmark",$A2="benchmark folder",$A2="physical
    > name",$A2="label part"), "n", "y")
    >
    > it doesn't check for case, so you don't have to cap the first
    > letter...
    >
    > The other thing you can do is make a table of what you are checking, I
    > put it in L1:L4
    >
    > =IF(ISERROR(MATCH(A2,L1:L4)), "y", "n")
    >
    > --
    > Bearacade
    >
    > ------------------------------------------------------------------------
    > Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016
    > View this thread: http://www.excelforum.com/showthread...hreadid=557100


    --

    Dave Peterson

  4. #4
    Forum Contributor
    Join Date
    06-01-2006
    Posts
    324
    Aye, true, thanks Dave

+ 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