Thread: Pi in VBA?
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Pi in VBA?

You could just assign the value to a constant directly...

Const PI = 3.14159265358979

Or you can let VB calculate it for you...

PI = 4 * ATN(1)

--
Rick (MVP - Excel)


"Prof Wonmug" wrote in message
...
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.