why does atan2 not work??

J

jaison

i would like to use atan2(x,y) in my program but i get an error: "Sub or
function not defined". i try to use atn but it yeild the wrong result.
 
C

Chip Pearson

ATAN2 is not a VBA function -- it is an Excel function.
Therefore, you have to call it via Application.WorksheetFunction.
E.g.,

res = Application.WorksheetFunction.Atan2(x, y)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
B

Bernard Liengme

Also, do remember computer work with angles in radians not degrees
See Help for functions RADIANS and DEGREES
best wishes
 
Top