You can change a cell containing a zero to a dash or a blank space by applying a custom number format. This does not alter the actual data value, so calculations will still treat the cell as a zero, but it will visually disappear from the sheet. You can also apply this to an entire column or range of numbers.
What You'll Need
- Microsoft Excel installed on your computer (desktop, tablet, or mobile app).
- A spreadsheet containing cells with values you wish to format.
Step-by-Step
- Open your Excel workbook. Navigate to the worksheet that contains the data you want to modify. For this guide, assume you have a column of numbers where you want to hide the zeros.
- Select the target cells. Click and drag your mouse over the specific cells or the entire column/row that contains the numbers you want to format. If you want to format the whole column, click the column letter header (e.g., Column A) at the top of the sheet.
- Open the Format Cells dialog. Right-click anywhere inside the selected cells. From the context menu that appears, select Format Cells. On a Mac, you can also press Ctrl + 1 or ⌘ + 1 to open this dialog.
- Access the Number tab. In the Format Cells window, ensure you are on the Number tab at the top of the pane. This is the default tab, but it is important to verify it.
- Select 'Custom'. Look through the list of categories on the left side of the dialog. Scroll down and select Custom. The center section will display a list of custom formats currently in use or a default format like
Generalor0. - Enter the format code. In the 'Type' text box at the bottom of the center section, you will enter the code that tells Excel how to display the number. To format a zero as a dash or hyphen, type the following code exactly as shown:
0;-0;-. - Understand the format code. The code
0;-0;-contains three parts separated by semicolons. They correspond to positive numbers, negative numbers, and text/zero values respectively. By entering-for the third part, you instruct Excel to display any value that is not positive or negative (specifically, zeros and text) as a dash. - Apply the settings. Click the OK button at the bottom of the dialog. The selected cells will now display dashes for their zero values. If you had text in those cells, it will also appear as a dash. To hide the text instead of showing a dash, you can type a single space in the third box (e.g.,
0;-0;) or leave it blank. - Verify the underlying data. It is crucial to remember that the cell value is still a number (0). If you sum the column, Excel will still count the hidden zeros. If you need to filter the data, the zeros will still be included in the filter results.
Common Mistakes
One frequent error is applying the custom format to a column that contains non-numeric text. If a cell contains text like "N/A" or "Pending" and you apply the 0;-0;- code, Excel will convert that text into a dash. To avoid this, ensure your data is clean or use a format code that handles text differently, such as 0;-0;"-".
Another mistake is confusing custom formatting with conditional formatting. While both can make zeros invisible, conditional formatting usually hides the text based on a rule (e.g., "if value is 0, make text white"). This can sometimes lead to formatting conflicts where the text is invisible but the cell still appears to have a value, or the formatting gets overwritten when the cell is edited.
Tips
For a cleaner look, you can format the dash to look like a hyphen or an em-dash. To do this, modify the code to 0;-0;-. This will display a standard hyphen for zeros. If you prefer a longer dash used in formal writing, you can type 0;-0;— (using the em-dash character). The dash will be centered in the cell.
If your data includes negative numbers, the code 0;-0;- will display negative numbers normally (e.g., -5) and zeros as dashes. If you want to display negative numbers in red or with parentheses, you can modify the second part of the code like this: 0;[Red]-0;-. This will show positive numbers as is, negative numbers in red, and zeros as dashes.
Troubleshooting
If the zeros are not changing to dashes, check if you are selecting the correct range. Sometimes, a stray cell outside the main range is selected, or the data is not actually a numeric zero (it might be a text string that looks like a number). Ensure the cell is formatted as a number and not as text. If the cell contains a formula that results in zero, the custom format will still work, but if the cell contains a formula that results in an error like #N/A, it will be converted to a dash.
If you apply the format and it looks wrong, double-check the text box for extra spaces or typos. The format code is case-insensitive, but the symbols (like semicolons) must be correct. If you want to revert the changes, simply select the cells, open the Format Cells dialog again, and change the type back to General or 0.
Frequently Asked Questions
Does this change the actual value in the cell?
No, applying a custom number format does not change the underlying value of the cell. The cell still contains the number 0, so if you use the cell in a formula or a chart, Excel will still treat it as zero.
Can I do this in Google Sheets?
Yes, the process is very similar. Select the cells, go to Format > Number > Custom number format, and enter the code 0;-0;-. Google Sheets will render the dash for zeros.
What if I want to hide zeros but keep the column width?
The custom format handles this automatically. The dash occupies the same width as the number, so the column width will remain unchanged, unlike hiding rows or using white text which can sometimes cause layout issues.
Will this work on dates that are zero?
Excel treats dates as serial numbers where January 1, 1900, is 1. A date value of 0 is technically January 0, 1900 (which is actually December 31, 1899), but if your data is strictly formatted as dates and you apply this format, it might display as a dash. It is safer to apply this format only to columns explicitly formatted as numbers or currency.
How do I format a zero as a blank space instead of a dash?
In the custom format code, enter a single space in the third section. The code should look like this: 0;-0; . When you apply this, the zero will disappear, leaving an empty cell.
Can I use this to format specific ranges based on a condition?
Yes, you can combine conditional formatting with custom formats. First, set a conditional formatting rule to format the cells with a zero as a specific color or style. Then, apply the custom format that turns zeros into dashes. The custom format will take precedence for the visual display.