Forum Discussion

Deano921's avatar
Deano921
Copper Contributor
Feb 12, 2024

Using or in an if Statement.

I am trying to understand the "Or" concept in Excel formulas.

 

I have 2 fields in a excel file I am using. A field called "Type"  and an amount field. The two conditions is the "Type" that I want to base the formula on are "Payment" and "Check". If the "Type" field is either a "Payment" or a "Check", I want to Multiply the "Amount" by a "-1". If the "Type" field is neither of these two types ("Payment" or "Check") I want the answer to be the "Amount" field only.  

The closest I can come to a formula to use is the following from an internet query I copies last month. It was trying to show the difference between using "Or" conditions between Excel and Access. I know how to use it in Access but cannot get it right for Excel.

The information in this query says in Excel use the "Or" function as follows -

     If(OR(Condition1,  Condition2), Value If True, Value if False}

I have tried various combinations of this concept as shown below but none are acceptable to my Excel program- I don't know how to correct the highlighted errors!

1st try -      

=IF(C13=OR("Payment","Check"),H13*-1,H13)

2nd try -

=IF(Or(C14="Payment","Check"),H14*-1,H14)

  • Deano921 

    =IF(OR(C13="Payment",C13="Check"),-H13,H13)

    =IF(OR(C13="Payment",C13="Check"),H13*-1,H13)

    Do these formulas return the intended result?

    • Deano921's avatar
      Deano921
      Copper Contributor
      Yes, the second one is Perfect! Thank you very much. I am now able to do a conditional "OR" in both Excel and Access!
      • Deano921's avatar
        Deano921
        Copper Contributor
        I really didn't know if I would get an answer or not. I have never used this technique to solve a formula problem before, Again, thank you very much for giving me the solution!

Resources