Of all the constants in Science, Engineering, and Mathematics, pi, or the ratio between a circle’s circumference and diameter is by far the most common. (Ok, I just made that up, but it seems about right.) Not surprisingly, then, it ends up in a ton of Excel calculations. Below, I’ve put together a comprehensive guide to working with pi in Excel.
Pi Function in Excel
Unless you’re the guy who memorized pi to over 70,000 digits, you can use a function to work with pi in Excel, instead of typing the number from memory.
The pi function can be found in the Math & Trig menu of Excel’s Formula tab:
But, unless you really like clicking in menus, you’d probably prefer to type the formula in a cell.
In that case you can type in any blank cell:
…and Excel returns the value of pi approximated to 15 figures, or 3.14159265358979.
Since pi is an irrational number, there is no limit to the number of decimals in it’s exact value. And although Excel can display 30 decimal points in a single cell value, it’s precision is limited to 15 figures. If you try to expand the number of decimals in the cell containing pi, any digits beyond the first 14 decimal places will be all zeroes.
The pi function returns a constant number, so it doesn’t require any arguments.
When to Use Pi in Excel
There are many, many times when you may want to use pi in Excel formulas. A few obvious examples are calculating the circumference of a circle from the diameter:
…calculating the area of a circle from the radius:
…calculating the volume of a sphere from the radius:
…and approximating the period of a pendulum:
The pi function can also be used as an alternative to the RADIANS or DEGREES functions for converting from degrees to radians or vice versa.
is equivalent to:
is the same as
Pi Name Error in Excel
There really isn’t much that can go wrong with the pi function, except for the #NAME? error. If you’re trying to use pi in an Excel formula and you are getting a #NAME? error, it’s because you’ve forgotten the opening and closing parentheses.
Remember, pi is a function in Excel, and even though it doesn’t take any arguments it still needs to be entered with parentheses to be recognized as a function by Excel.
Pi in Excel VBA
If you need the value of pi multiple times in your code, it’s going to be really irritating to type Application.WorksheetFunction.Pi() over and over again.
Instead, create a variable called “pi” and set it equal to the results of the worksheet function.
pi = Application.WorksheetFunction.Pi()
Then you can use the variable “pi” in all the subsequent lines of VBA code for that function or subroutine.
The precision of the value stored in the variable will be affected by whether it is a “Single” or “Double” data type.
When the variable is stored as a Single, it only contains 7 figures (as seen in the Immediate window):
However, when the variable is stored as a Double, it contains all 15 figures, the same as those returned by the worksheet function:
Pi Symbol in Excel
If you want to enter the pi symbol, or Greek letter “π”, into a cell in your worksheet, there are a couple of different ways to accomplish this:
Excel Character Code for Pi
The quickest way is to use the Excel ASCII character code for pi. To add the pi symbol to a cell this way, hold down the ALT Key and type 227 on the number pad. Then release the ALT key, and the symbol, or Greek letter, “π” will be inserted in the cell.
Insert Pi Symbol
If you forget the ASCII code, you can always enter the Greek letter through the symbol dialog.
In the ribbon, click on the “Insert” tab, and then click “Symbol” on the far right of the menu.
In the Symbol dialog box, choose “Greek and Coptic” from the “Subset” dropdown. Then find the letter “π” and double click it to insert it to the cell.
Pi in Excel for Mac
The pi function works the same in Excel for Mac as it does in Excel for Windows.
The shortcut for entering the symbol into a cell is different though. On a Mac, hold down the Option key, and press “P”.