Share via

Problem with statement priority in a nested If (Excel 2016)

Anonymous
2017-07-28T20:44:01+00:00

First off here is my code:

=IF(MOD(A1,3)=0,"Fizz",IF(MOD(A1,5)=0,"Buzz",IF(AND(MOD(A1,3)=0,MOD(A1,5)=0),"FizzBuzz",A1)))

What I want to happen is if the number in A1 is a multiple of 3 return Fizz, if a multiple of 5 return Buzz, and if a multiple of both 3 and 5 return FizzBuzz. Otherwise return the number in A1. All is well and good until 15, which should return FizzBuzz. Instead I get Fizz. So it's taking the first true condition and stopping, which I understand is what it is supposed to do. So I feel like I am missing an or maybe? somewhere. I just don't know where to put it. Am at least on the right track?

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2017-07-28T22:33:51+00:00

Try this:

=IF(AND(MOD(A1,3)=0,MOD(A1,5)=0),"FizzBuzz",IF(MOD(A1,3)=0,"Fizz",IF(MOD(A1,5)=0,"Buzz",A1)))

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2017-07-28T22:49:24+00:00

    Perfect Thanks!

    Was this answer helpful?

    0 comments No comments