Excel - Calculating Pi

Calculating piIf you are finding the inbuilt excel function for =Pi() is just a bit too dull, there a handy function to calculate Pi on the fly.

You may want to use it sparingly though, too many times in one spreadsheet or to many decimal places and you'll grind to a halt as it is a bit processor hungry!:

Function myPi(places)
'Places is the number of decimal place accuracy you want
x = 1
a = 4
b = -1
Do While Round(c, places) <> Round(a, places)
c = a
a = a + (4 / (x * 2 + 1)) * b
b = b * -1
x = x + 1
myPi = Round(a, places)
End Function

Tags : excel pi formula

Search Posts

Back to top