Written by Allen Wyatt (last updated September 4, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and 2021
Henk asked if there is a way in Excel to display a number using six digits, independent of the placement of the decimal point. For instance, 0.1 would be displayed as 0.10000, 200 would be displayed as 200.000, and 25000 would be displayed as 25000.0.
Unfortunately, there is no formatting that will do the trick; all display formatting seems to be dependent on the position of the decimal point. You can format a display for a specific number of digits after the decimal point, but that number of digits will be used regardless of how many digits appear before the decimal point.
Several ExcelTips subscribers came up with suggestions that involve using formulas to display the number as desired. For instance, the following formula will display the value in A1 using six digits:
=FIXED(A1,IF(ABS(A1)<1,5,5-INT(LOG(ABS(A1)))),TRUE)
Other readers provided formulas that relied on converting the number to a text string and displaying it as such. Converting a number to its textual equivalent, however, has the distinct drawback of no longer being able to use the number in other formulas. (Remember—it is text at this point, not a number.) The above formula does not have that limitation.
If you wanted to, you could also use a macro to set the formatting within a cell that contains a value. The advantage to such a macro is that you don't have to use a cell for a formula, as shown above. The drawback to a macro is that you need to remember to run it on the cells whenever values within them change. The following macro is an example of such an approach:
Sub SetFigures() Dim iDecimals As Integer Dim bCommas As Boolean Dim sFormat As String Dim CellRange As Range Dim TestCell As Range bCommas = False 'Change as desired Set CellRange = Selection For Each TestCell In CellRange If Abs(TestCell.Value) < 1 Then iDecimals = 5 Else iDecimals = 5 - Int(Log(Abs(TestCell.Value)) / Log(10#)) End If sFormat = "0" If bCommas Then sFormat = "#,##0" If iDecimals < 0 Then sFormat = "General" If iDecimals > 0 Then sFormat = sFormat & _ "." & String(iDecimals, "0") TestCell.NumberFormat = sFormat Next TestCell End Sub
In order to use the macro, simply select the cells you want to format, then execute it. Each cell in the range you selected is set to display six digits, unless the number in the cell is too large or too small.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10920) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and 2021. You can find a version of this tip for the older menu interface of Excel here: Using an Exact Number of Digits.
Program Successfully in Excel! This guide will provide you with all the information you need to automate any task in Excel and save time and effort. Learn how to extend Excel's functionality with VBA to create solutions not possible with the standard features. Includes latest information for Excel 2024 and Microsoft 365. Check out Mastering Excel VBA Programming today!
What are you to do if you are trying to format a worksheet, only to find out that one of the tools you need is not ...
Discover MoreExcel allows you to specify colors for the interior of cells in your worksheet. If you want those colors to be set ...
Discover MoreIf you need to change fonts used in a lot of different workbooks, the task can be daunting, if you need to do it ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2021-09-04 12:17:12
Tomek
You could use scientific notation where every number is displayed for example as n.nnnn+EE where n.nnnn is a number from 1.0000 to 9.9999 (or 0.0000 if the value is 0)
You can specify the number of digits after decimal (one less than desired number of digits).
It takes some time to get used to this format though.
2021-09-04 05:43:57
Ewen McLaughlin
This is a very common issue in science and engineering where the number of significant figures indicates the precision of the value. The number of decimal places, easily formatted in Excel, isn't the same.
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments