0

I have a cell that I want to calculate this if statement =IF(E7>D7,E7-D7,D7-E7) but only if the Cell G7 is yes.

I wrote this formula =IF(G7=yes,(IF(E7>D7,E7-D7,D7-E7)),"n/a") but it doesn't work, how would I fix it?

3
  • How exactly it doesn't work? Commented Jul 4, 2019 at 16:34
  • i get the #Name? error
    – shelby
    Commented Jul 4, 2019 at 17:04
  • @shelby, you are getting #Name error because in IF(G7=yes the yes is without quotes and it must be like "Yes" or "yes". Since it's without quotes, Excel considers it as Reserve word (Function/Command) and Excel does't have any !! Commented Jul 5, 2019 at 7:07

2 Answers 2

4

You could also get the absolute value of the difference:

=IF(G7="yes",ABS(E7-D7), "n/a")
0

You don't need to add extra brackets for the nested IF statement. Try this:

=IF(G7="yes",IF(E7>D7,E7-D7,D7-E7), "n/a")
3
  • it removed the Name error, but even with Yes in G7, it still returns n/a
    – shelby
    Commented Jul 4, 2019 at 17:12
  • Odd. It's should be working snag.gy/xsBfD4.jpg. Start a new sheet and try it again. The cell format might be irregular.
    – Humble Val
    Commented Jul 4, 2019 at 17:18
  • That worked, I had the yes and no options as a drop down menu, so i think that might have been the issue, once i got rid of that it woked..
    – shelby
    Commented Jul 4, 2019 at 17:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .