Search code examples
vbaexcelexcel-2007

Tan() Returns Wrong Value


I am trying to calculate angle between three points and I need to use the Tangent function tan(). The weird thing is that VBA return wrong value.

for example:

tan(209) = 0.554309051

but in VBA:

tan(209) = -.696695985548265

My friend told me about something called "Normalize". but I didn't understand what he's talking about and how to do it. Why is this happening?


Solution

  • According to this VBA uses radians. Convert degrees into radians , ( degrees * 2 * pi) / 360

    tan((209 * 2 * 3.14)/360)