How to Make 0 a Dash in Excel
In this article
To display a zero as a dash in Excel, use a custom number format: select the cells, press Ctrl+1 (Cmd+1 on Mac), go to the Number tab, choose Custom, and type 0;-0;"-" in the Type box, then click OK. This replaces every zero with a hyphen while leaving positive and negative numbers unchanged. You can also use the built-in Accounting format, which shows zeros as dashes by default, or apply conditional formatting to change the font color of zeros to match the background. The custom format is the most flexible because it works on any cell and does not alter the underlying value.
What You'll Need
- Microsoft Excel (any modern version for Windows or Mac; the steps are nearly identical, though dialog labels may differ slightly by version and region).
- A worksheet containing numeric cells where zeros should appear as dashes.
- Basic familiarity with selecting cells and opening the Format Cells dialog.
Step-by-Step
- Select the cells you want to format. Click and drag to highlight a range, or press Ctrl+A (Cmd+A on Mac) to select the entire worksheet if you want the change everywhere. You can also select non-adjacent cells by holding Ctrl (Cmd on Mac) while clicking.
- Open the Format Cells dialog. Press Ctrl+1 (Cmd+1 on Mac) or right-click the selection and choose Format Cells. The dialog opens with the Number tab active.
- Choose the Custom category. In the Category list on the left, scroll down and click Custom. The Type box on the right becomes editable and shows the current format code.
- Enter the custom format code. Clear the Type box and type exactly: 0;-0;"-" (without the quotes around the whole code, but include the double quotes around the dash). This code has three sections separated by semicolons: the first section formats positive numbers, the second formats negative numbers, and the third formats zero. The third section
"-"tells Excel to display a hyphen for any zero value. - Confirm the preview. The Sample box above the Type field should show a dash for a zero value. If you see something else, check that you typed the semicolons and quotes correctly.
- Click OK. The selected cells now display a dash wherever the value is zero. The underlying value remains 0, so formulas and calculations are unaffected.
- Optional: apply to other cells. Use the Format Painter (Home tab > Format Painter) to copy the format to additional ranges, or repeat the steps for each range.
Common Mistakes
- Using the wrong number of sections. A custom format can have up to four sections (positive; negative; zero; text). If you only provide two sections, the zero section is omitted and zeros may display as 0 or as the positive format. Always include the third section for zeros.
- Forgetting the quotes around the dash. The dash must be enclosed in double quotes (
"-") so Excel treats it as text. Typing just-without quotes can be interpreted as a minus sign and may cause errors or unexpected results. - Applying the format to text cells. Custom number formats only affect numeric values. If a cell contains text (even a text-formatted zero like '0), the format will not change it. Ensure the cells are truly numeric.
- Expecting the change to affect formulas. Formatting changes only the display. If you reference a zero cell in a formula, it still evaluates as 0. To change the actual value, you would need to replace zeros with dashes using a formula or Find & Replace, but that converts numbers to text and may break calculations.
- Using the Accounting format and then editing. The Accounting format shows zeros as dashes by default, but if you later apply a different format, the dashes revert to zeros. Custom format is more persistent.
Tips
- To show a dash for zero but keep negative numbers in parentheses, use a format like
0;(0);"-". - If you want a dash for zero and also want to hide the minus sign for negatives, use
0;0;"-". - You can add color codes to the format, for example
[Red]0;[Blue]-0;"-"to color positives red, negatives blue, and zeros as a plain dash. - To apply the format to an entire column, click the column header to select it, then apply the custom format. New entries in that column will inherit the format.
- If you need to export the data, remember that the dash is only a display format; the underlying value is still zero. When pasting to other programs, the zero may appear instead of the dash.
- For a quick visual alternative, use conditional formatting: select the range, go to Home > Conditional Formatting > New Rule > Format only cells that contain > Cell Value equal to 0, then set the font color to match the background (usually white). This hides zeros without changing the number format, but the zero is still there if you click the cell.
Troubleshooting
- The dash does not appear; zeros still show as 0. Check that the cells are formatted as numbers, not text. Select the cells, press Ctrl+1, and on the Number tab ensure the Category is not Text. Also verify the custom format code has three sections and the third section is
"-". - All numbers turned into dashes. You likely applied the format to cells that contain only zeros, or you accidentally used a format like
"-";"-";"-". Reopen Format Cells and correct the code to0;-0;"-". - The format code is rejected with an error. Make sure you are using straight double quotes ("), not curly quotes. Also check that semicolons are used as separators, not commas (unless your region uses commas as list separators; in some locales, Excel uses a different separator character). If you are unsure, try typing the code with semicolons first; Excel will often correct it automatically.
- Zeros in formulas still calculate as zero. This is expected. Number formats do not change values. If you need the actual value to be a dash, you must convert the number to text, for example with a formula like
=IF(A1=0,"-",A1), but be aware this changes the data type and may affect downstream calculations. - The custom format does not stick after reopening the file. Ensure you save the workbook in a format that supports formatting, such as .xlsx. If you save as .csv, all formatting is lost.
- You want to remove the dash format later. Select the cells, open Format Cells, choose the Number category, and pick a standard format like General or Number. The zeros will reappear.
Frequently Asked Questions
Can I make zeros appear as dashes without changing the number format?
Yes, you can use conditional formatting to set the font color of zero cells to match the background, effectively hiding them. However, the zero remains in the cell and will show in the formula bar. The custom number format is more straightforward and does not rely on color tricks.
Will this work in Excel for Mac?
Yes. The steps are the same: select cells, press Cmd+1, go to Custom, and enter the format code. Menu labels may differ slightly, but the Format Cells dialog is essentially identical.
Does the dash format affect sorting or filtering?
No. Sorting and filtering use the underlying values, so zeros are treated as zeros regardless of how they are displayed. This is an advantage of number formatting over converting to text.
Can I use a different character instead of a dash?
Yes. Replace the dash inside the quotes with any text you like, such as "N/A" or "nil". The format code would be 0;-0;"N/A".
Why do some zeros still show as 0 after applying the format?
Those cells may contain text values (e.g., entered with a leading apostrophe) or may have a different format applied individually. Select them, clear all formatting (Home > Clear > Clear Formats), and reapply the custom format.
Is there a built-in format that shows zeros as dashes?
The Accounting format does this by default. You can find it under Format Cells > Number > Accounting. However, it also adds currency symbols and decimal alignment, which may not suit all uses. The custom format gives you more control.