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?

  • How exactly it doesn't work? – Máté Juhász Jul 4 '19 at 16:34
  • i get the #Name? error – shelby Jul 4 '19 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 !! – Rajesh S Jul 5 '19 at 7:07
4

You could also get the absolute value of the difference:

=IF(G7="yes",ABS(E7-D7), "n/a")
| improve this answer | |
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")
| improve this answer | |
  • it removed the Name error, but even with Yes in G7, it still returns n/a – shelby Jul 4 '19 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 Jul 4 '19 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 Jul 4 '19 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.