Trigonometric Functions in VBA

Deep within the bowels of the Microsoft on-line help can be found:

http://msdn2.microsoft.com/en-us/library/csfk8t62(VS.85).aspx

which lists  the derivation of trigonometric functions not provided by VBA.  Not included in this list is ATan2(), which is strange because this is the one trigonometric function that is really essential for anyone doing trigonometric or vector based calculations.

The file: http://www.interactiveds.com.au/software/TrigFuncsVBA.zip provides UDF versions of all the functions listed on the Microsoft site, plus 2 versions of ATan2().

See the next post for an illustration of the advantage of using a UDF for Excel functions that are not included in VBA, rather than using the WorksheetFunction object.

Posted in Excel, Maths, UDFs | Tagged | 7 Comments

Hello World in a UDF

An Excel User Defined Function (UDF) is probably the single most useful feature that remains unused by the majority of users. This post will provide a brief introduction with the obligatory “Hellow World” program, followed by something only a little more complicated and much more useful.

Excel UDFs allow users to write their own functions that operate in a similar way to the built in functions. It would for instance be possible, and in fact quite easy, to write a MySum() function that behaved exactly the same as the Excel Sum() function. Fortunately it is also possible to write functions providing functionality that is not built into Excel.

Continue reading

Posted in Excel, UDFs | Tagged , | 4 Comments