Thread
:
Pi in VBA?
View Single Post
#
26
Posted to microsoft.public.excel.programming
Walter Briscoe
external usenet poster
Posts: 279
Pi in VBA?
In message of Sun,
28 Sep 2014 05:35:05 in microsoft.public.excel.programming, Auric__
writes
Walter Briscoe wrote:
In message of
Thu, 25 Sep 2014 14:32:18 in microsoft.public.excel.programming,
writes
On Tuesday, April 28, 2009 1:00:22 AM UTC-4, Prof Wonmug wrote:
What's the best way to get the most accurate value for pi in a VBA
function?
Excel 2007 has a pi() worksheet function, but there doesn't appear to
be a corresponding VBA function. The best I could come up with is
C = 2 * Application.WorksheetFunction.Pi() * R
That works, but it's a litte messy.
This helped. Thank you.
By definition, pi = 4*arctan(1).
?4*atn(1)
3.14159265358979
Since the value of pi won't ever change (barring a fundamental change in the
universe) I just assign it to a constant if I need it:
Const PI = 3.14159265358979
I failed to notice that this thread dates from April 28, 2009.
did not give a reason for resurrecting it.
I like Const PI = 3.14159265358979
I prefer Const PI As Double = 3.14159265358979
but there is no difference in meaning. YMMV. ;)
--
Walter Briscoe
Reply With Quote
Walter Briscoe
View Public Profile
Find all posts by Walter Briscoe