How to Add Dashes in Excel: Formats, Formulas and Flash Fill

The quickest way to add dashes to numbers in Excel is a custom number format. Select the cells, press Ctrl + 1, choose Custom, type a pattern such as 000-000-0000 in the Type box, and select OK. The number 5551234567 then displays as 555-123-4567. For ZIP codes that are still buried inside full addresses, start by learning how to split addresses into city, state and ZIP columns.

A format only changes how the number looks. If you need the dashes to actually be in the data, for example to export a CSV file or paste into another program, use a formula or Flash Fill instead. This guide covers both, plus how to remove dashes and the problems with long ID numbers that trip people up.

Which method should you use?

You want toUseDashes stored in the cell?
Make phone numbers, SSNs or ZIP+4 codes easier to read on screenCustom or Special number formatNo, display only
Export or copy the values with dashesTEXT or REPLACE formula, or Flash FillYes
Fix a one-off column quickly without formulasFlash FillYes
Join separate cells with a dash between themTEXTJOIN or the & operatorYes
Take dashes outFind and Replace, or SUBSTITUTERemoves them

These steps are for Excel for Microsoft 365 and Excel 2021 or later on Windows. Most also work on a Mac; the menu names are noted where they differ.

Method 1: Add dashes with a custom number format

  1. Select the cells or the whole column that holds the numbers.
  2. Press Ctrl + 1 (on a Mac, Command + 1). You can also go to the Home tab and select the small arrow in the corner of the Number group.
  3. In Format Cells, open the Number tab and select Custom at the bottom of the Category list.
  4. Click in the Type box, delete what’s there, and type your pattern (see the table below).
  5. Check the Sample preview at the top, then select OK.
Excel Format Cells dialog with the custom format 000-000-0000
A custom format adds dashes on screen only.

Microsoft’s guide to creating a custom number format covers the same dialog. Click a cell afterward and look at the formula bar: it still shows the plain number, which is how you know the dashes are only on screen.

Format codes that add dashes

Type this codeThe numberDisplays as
000-000-00005551234567555-123-4567
000-00-0000123456789123-45-6789
00000-000098101123498101-1234
0000-0000-00002026113056782026-1130-5678
###-####5551234555-1234

Each 0 is a digit placeholder that shows a zero if the number is too short, so 12345678 with 000-00-0000 shows as 012-34-5678. A # shows only the digits that exist. Microsoft’s list of number format codes confirms both, and also shows that a hyphen can be typed straight into a code with no quotation marks. Use 0 for IDs with a fixed length and # when lengths vary.

Use the built-in Special formats instead

For US data, Excel has ready-made patterns. In Format Cells, choose Special in the Category list and pick Zip Code + 4, Phone Number or Social Security Number. Microsoft’s page on displaying Social Security numbers walks through it. These types only appear when the Locale (location) is set to English (United States). Note that the Phone Number type shows the area code in parentheses, (555) 123-4567, rather than all dashes.

Method 2: Add real dashes with a formula

Formulas create a new value that contains the dashes as text. Put the formula in an empty column next to your data.

TEXT applies a pattern

If A2 holds 5551234567, this returns 555-123-4567:

=TEXT(A2,"000-000-0000")

The TEXT function uses the same codes as custom formats. The result is text, so you can’t do math with it, which is fine for phone numbers and IDs.

REPLACE inserts at a position

REPLACE works when the value is already text or contains letters, for example a product code like AB12345. With a length of 0, it inserts without removing anything:

=REPLACE(A2,3,0,"-") turns AB12345 into AB-12345.

Nest it to add more than one dash. Work from right to left so the earlier positions don’t shift: =REPLACE(REPLACE(A2,7,0,"-"),4,0,"-") turns 5551234567 into 555-123-4567. Microsoft documents the arguments in its REPLACE reference.

Join separate cells with a dash

If the parts are in different columns (area code in A2, prefix in B2, line in C2), use =TEXTJOIN("-",TRUE,A2:C2). The TEXTJOIN function puts the delimiter between each value and skips empty cells when the second argument is TRUE. In older versions, =A2&"-"&B2&"-"&C2 does the same. For a similar technique with commas, see these steps to combine text with commas in Excel.

Replace the originals with the results

Once the formula column looks right, select it, press Ctrl + C, right-click the original column, and choose Paste Values. Then delete the helper column.

Method 3: Use Flash Fill (no formula)

  1. In the column next to your data, type the first value the way you want it, for example 555-123-4567 next to 5551234567.
  2. Press Enter, then start typing the second one. Excel usually shows a gray preview of the rest of the column.
Excel Flash Fill preview adding dashes to phone numbers
Start typing the next example to show the gray Flash Fill preview, then press Enter to accept it.
  1. Press Enter to accept, or select the cell below your example and press Ctrl + E (or Data > Flash Fill).
  2. Spot-check a few rows. Flash Fill guesses the pattern from your example, so give it a second example if it guesses wrong.

Microsoft’s page on using Flash Fill has more examples. The results are plain values, so they don’t update if the original data changes.

Long numbers and leading zeros

Two Excel limits cause most “my dashes are wrong” problems, both explained in Microsoft’s article on keeping leading zeros and large numbers:

  • Leading zeros disappear. Type 01234 and Excel stores 1234. A format with enough 0 placeholders puts the zero back on screen, which is why 00000-0000 works for ZIP codes that start with 0.
  • Only 15 digits are kept. Excel stores numbers to 15 significant digits, so a 16-digit account or tracking number turns its last digit into a 0. Formats can’t fix this. Format the column as Text before typing or pasting, or start the entry with an apostrophe, then use REPLACE or Flash Fill to add dashes. This guide to using apostrophes and single quotes in Excel explains how the apostrophe trick works.

Custom number formats also don’t affect cells that contain text. If a format seems to do nothing, check whether the numbers are stored as text (they’re often left-aligned, sometimes with a small green triangle). Either convert them to numbers or use REPLACE.

Remove dashes

  • Dashes from a format: select the cells, press Ctrl + 1, and choose General.
  • Typed or formula dashes: select the range, press Ctrl + H, type a dash in Find what, leave Replace with empty, and select Replace All. Microsoft’s Find and Replace guide covers the options. Select only the column you want first, or Excel replaces dashes across the whole sheet, including in dates and negative numbers typed as text.
  • With a formula: =SUBSTITUTE(A2,"-","") returns the value without dashes and leaves the original alone.

If Excel turns a value like 1-15 into a date as you type, that’s automatic date conversion, not a dash problem; these steps for stopping Excel from changing entries to dates fix it.

A note on Social Security numbers

If your sheet holds SSNs, Microsoft’s SSN page recommends not storing full numbers when you can avoid it. To show only the last four digits, use ="XXX-XX-"&RIGHT(A2,4) in a separate column, then hide and protect the original.

Questions and fixes

Why do I see ##### instead of my number?

The column is too narrow for the formatted value. Double-click the right edge of the column header to widen it.

Why did my format show extra zeros?

The pattern has more 0 placeholders than the number has digits. Count the digits and match the code, or use # for positions that may be empty.

Will new entries get dashes automatically?

Yes, if you formatted the whole column. Any number typed into it later uses the same format. Formula and Flash Fill results don’t extend themselves, so copy the formula down for new rows.

Can I use other separators?

Yes. In formulas and Flash Fill, use any character you like. In a format code, a space works as is (000 000 0000), but a period must go in quotation marks (000"."000"."0000), because an unquoted period is read as a decimal point.

About the author

Matt Williams is the writer and editor behind TechInfoHome. He holds a degree in computer science and has more than 10 years of experience working in IT. More about TechInfoHome.