This is something kind of nasty we recently discovered - in EXCEL, the arguments for atan2 and atan2d (4-quadrant arctangent) are backwards from almost every other implmentation. atan2 is a function that returns the angle from two arguments, the "rise" and the "run", or Y and X. atan2 returns the angle in radians, and atan2d returns the angle in radians.
Every computer language aside from EXCEL has these arguments in this order - alpha = atan2(y,x), logically, Y is the "rise" and X is the "run" For some unknown reason (no doubt associated with Bill Gates close personal relationship to Satan) the same function in EXCEL expects the first argument to be the "run"/X and the second argument to be the "rise"/Y. If you don't know this and assume the standard function, of course you get the wrong answer.
Programmer beware, my recommendation remains to never use EXCEL for anything outside accounting. You can get a home version of MATLAB for something like $175, fully functional, it never expires (although you only get updates for two years) and has it right, using close-to-standard C syntax, or use GNU FORTRAN, Python, or any other language. Or spend days on something and getting the wrong results until you find what this and other f-ups Microsoft has in store for you. Also note taht because this is backwards in EXCEL, it is also backwards in NUMBERS, for compatibility reasons.
Brett