The effect of the two is the same, but I would say that the precise meaning is different. They lead to the same thing in the end, though.
he just said no to anything containing sugar
This means that he refused any time he was offered something containing sugar.
he just said no to everything containing sugar
This means that he pro-actively decided that he would have nothing with sugar.
The difference is subtle, this understanding may not be consistent between native speakers, and it doesn't really matter because it amounts to the same thing in the end.
Anything and everything are different words and have different meanings, but not infrequently the overall sense of a sentence is the same with either. Do not make the mistake of thinking they are interchangeable generally, though. After all, you wouldn't want to ask someone:
Can I get you everything?