Suppose we have a list of numbers and we want to separate them into different parts by dash, how can we quickly add dashes into the numeric string? This article will provide you two ways to add dashes, one is to add dash by formula, the other one is set number format by custom in format cells. We also provide the method to add dashes for Phone Number and SSN.
In above table, change 20200301 in A1 to 2020-03-01 in C1, we need to add two dashes to separate the string, though we can add dash manually one by one, it is still a little complex for users. So, we need a simple way to add dashes now.
Table of Contents
1. Add Dashes by Formula
Step1: In C1, enter the formula:
In this formula, ????-??-?? is the final format of string.
Step2: Click Enter to get result. Verify that numeric string is displayed into three parts and connected by dash properly.
Step3: Drag the fill handle to fill C2 to C6. Verify that all numeric strings are add separated by dashes properly.
1.You can set format_text parameter depends on your demand. For example, in this case if you enter =TEXT(A1,”??-??-??-??”), then numeric string 20200301 will be displayed as 20-20-03-01 finally.
2.You can use other formula to set format for string. For example, enter formula =LEFT(A1,4)&”-“&MID(A1,5,2)&”-“&RIGHT(A1,2). Then you can get the same result.
2. Add Dashes by Set Format as Custom in Format Cell
Step1: Copy A column to C column.
Step2: Select C2:C6, then right click to load menu, select Format Cell.
Step3: In Format Cell, under Number tab, select Custom from Category list. Then in Type textbox, enter 0000-00-00. Then after typing the Type, in Sample field, 2020-03-01 is displayed. Then click OK.
Step4: Verify that dashes are added into string as we expect.
3. Add Dashes by Set Format as Special in Format Cell
If we want to add dashes into number with fixed format like Phone Number or SSN, you can directly select Special->Type->Phone Number (or Social Security Number) in Format Cells, see screenshot below.
Screenshot 1: Set number to Phone Number.
Screenshot 2: Set number to Social Security Number.
4. Vdieo: Add Dashes into Numeric String
In this tutorial video, we’ll explore two methods to add dashes for improved readability in Microsoft Excel 2013./2016/2019/365.
5. SAMPLE FIlES
Below are sample files in Microsoft Excel that you can download for reference if you wish.