+ Reply to Thread
Results 1 to 6 of 6

Excel 2007 : If statement - logic syntax

  1. #1
    Registered User
    Join Date
    04-26-2009
    Location
    Mojave Desert
    MS-Off Ver
    Excel 2007
    Posts
    2

    If statement - logic syntax

    I am trying to make a logical expression that checks for one of 4 conditions, and returns a displayed value for each of those conditions, but returns an error message if one of those conditions is not met.

    If cell C5 = "N", then C10 = "N", if C5="S", then C10 = "S", if c5="+", then c10="+", if c5="-", then c10="-", if C5 is not equal to one of the previous four conditions, then c10="C5 error"

    Restated another way for clarity:

    If c5=N,S,+,or -, then c10=c5, else c10="c5 error"

    So, what is the proper syntax for this? Sorry that my jargon is not up to speed, this is the only way I know how to ask the question.Thanks for the help.
    Last edited by Omegaman; 04-27-2009 at 12:16 AM.

  2. #2
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432

    Re: Need help with logic syntax

    Hi Omegaman,

    A formula can not change the value in another formula which is the reason that this wont work.

    I would either use a VBA procedure to check and make all cell value changes or use a formula in the cell you want to change.

    Not sure if that makes sense, but hope it helps somehow
    There are only 10 types of people in the world:
    Those who understand binary, and those who don't!

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: Need help with logic syntax

    Maybe

    =IF(C5="N","N",IF(C5="S","S",IF(C5="+","+",IF(C5="-","-","C5 error!"))))
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Need help with logic syntax

    Or in C10, since you're using Excel 2007,

    =IFERROR(LOOKUP(C5, {"-","+","N","S"}), "C5 error")
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    04-26-2009
    Location
    Mojave Desert
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: If statement - logic syntax

    =IF(C5="N","N",IF(C5="S","S",IF(C5="+","+",IF(C5="-","-","C5 error!"))))
    That worked perfect Noob! Thanks a lot. It's good to be smart 'cuz then you know stuff!!!

  6. #6
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: If statement - logic syntax

    Another possibility, no nesting if statements required ...

    =IF(OR(C5="N",C5="S",C5="+",C5="-"),C5,"C5 error!")

+ 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