+ Reply to Thread
Results 1 to 11 of 11

If /then statement

Hybrid View

  1. #1
    Registered User
    Join Date
    09-19-2008
    Location
    dallas, tx
    Posts
    1

    If /then statement

    I want to write a spread sheet that has the following formula.
    If cell A2 equals x and B2 equals x then C2 equals 1, if either A2 or B2 is zero then c2 equals zero. Can anyone help?

  2. #2
    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
    One way

    =IF(COUNTIF(A2:B2,"x")=2,1,IF(COUNTBLANK(A2:B2)>=1,0,""))
    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 !!!

  3. #3
    Forum Contributor
    Join Date
    02-12-2008
    Location
    Doha-Qatar
    MS-Off Ver
    Excel 2007
    Posts
    137
    Hi,

    If you mean to say that the value in A2 is the same in B2, then you can use in C2 : =IF((A2=B2),1,IF((A2<>B2),0))

    Please note the my formula still needs some amendment when the values in A2 & B2 is 0, i do not know how to make this amendment

    Thanks every body for further assistance

    Regards

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Perhaps

    =IF(A2=B2,1,IF(OR(A2=0,B2=0),0,""))

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    paul that gives 1 for a2=0, b2=0 as thats true
    =if(or(a2=0,b2=0),0,if(a2=b2,1,""))

  6. #6
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Martin, extremely large values of -1 could be miscalculated by Excel due to binary math, causing the formula to give incorrect results.

    Ok, just kidding. Good eye!

  7. #7
    Registered User
    Join Date
    09-23-2008
    Location
    mobile
    MS-Off Ver
    07
    Posts
    43
    Quote Originally Posted by pjoaquin View Post
    Martin, extremely large values of -1 could be miscalculated by Excel due to binary math, causing the formula to give incorrect results.

    Ok, just kidding. Good eye!
    Are you talking about something like repeating decimal places being rounded off or other unlogical errors you wouldn't expect?

  8. #8
    Registered User
    Join Date
    09-23-2008
    Location
    mobile
    MS-Off Ver
    07
    Posts
    43
    That is kind of like the Second Derivative Test when you "check that each of these functions has precisely one critical point x = 0 and that at this point the second derivative is zero in all three cases." or is it .". or '. Can you show me code with complex formulas using a ReplaceIF?

  9. #9
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Contextions, are you serious? If so, I apologize. That post was a complete joke based on the quote "2 + 2 = 5, for extremely large values of 2." Google™ it; you can even buy t-shirts and mugs.

    Hence the "Just kidding... wink" bit.

  10. #10
    Registered User
    Join Date
    09-23-2008
    Location
    mobile
    MS-Off Ver
    07
    Posts
    43
    Theoretically you could use excel to display 2 + 2 = 5 for large values of 2 if entries were rounded to nearest .5 < higher whole number, huh? We should make a new trademark with the code!

  11. #11
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,937
    there's also this posibility:

    =--AND(A1="x",B1="x")
    Ben Van Johnson

+ 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. Create statement from cells in workbook
    By Andy Stern in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-04-2008, 04:46 AM
  2. Nested IF Statement with Multiple Criteria
    By Hoopsah in forum Excel General
    Replies: 6
    Last Post: 07-23-2007, 10:01 AM
  3. With Statement Questions
    By OzTrekker in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-02-2007, 02:44 AM
  4. G/L Income Statement Template Setup
    By pinny in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-28-2006, 08:12 PM
  5. advanced (i think) if statement help
    By ukrockhit in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 11-06-2006, 11:41 AM

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