How To Use Excel Functions to Isolate Data Separated by Dashes

Written by:  • Edited by: John Garger
Updated Jan 20, 2010
• Related Guides: Microsoft | Excel

Data in regular formats such as those with multiple dashes can be difficult to segment into parts. Learn how to use Excel formulas to separate data that uses multiple dashes.

Strategy: There is an optional third argument in the FIND function. This tells Excel to start looking after a certain character position in the text. In this case, to find the second dash, you want Excel to start looking after the location of the first dash.

1) As in the prior examples, use =FIND(“-”,A2) in cell F2 to locate the first dash.

2) Enter =FIND(“-”,A2,F2+1) in cell G2, as shown in Fig. 277. The F2+1 parameter tells Excel that you want to find a dash starting in the fourth character position of cell A2.

3) Enter =LEFT(A2,F2–1) in H2. The formula in H2 locates the first segment of the part number.

4) Enter =MID(A2,F2+1,G2–F2) in I2. The formula in I2 locates the middle segment of the part number.

5) To get the right segment of the part number, you can use the RIGHT function. Just like the LEFT function, the RIGHT function requires a cell and the number of characters from the right side of the item number. To find the number of characters, use =LEN(A2)–G2.

Enter the resulting formula, =RIGHT(A2,LEN(A2)–G2), in J2. See Fig. 278.

Gotcha: All of these formulas are trusting that the vendor always included two dashes in the item number. If an item number exists without a second dash, the second FIND function would return a #VALUE! error, leading to errors in the calculation for the second and third items. Before converting formulas to values and deleting the original part number, sort the data by column F and then sort descending by column G. As shown in Fig. 279, any #VALUE! errors will sort to the top of the dataset, where you can locate and correct the errors in the part number.

Summary: Using combinations of FIND, LEN, MID, LEFT, and RIGHT, it is possible to parse nearly any data imaginable.

Functions Discussed: =FIND(); =LEN(); =MID(); =LEFT(); =RIGHT()

See More Microsoft Excel tips

Images

Fig. 276Fig. 277Fig. 278Fig. 279

Comments

Showing all 3 comments
 
Daniel Turgel Dec 23, 2010 11:12 AM
Mid Function
Thanks John, that worked perfectly!

Daniel
John Garger Dec 23, 2010 10:04 AM
Mid Function
Use the mid function. The following should work for you:

=mid(a1,26,200)

This will take the text in cell A1 and starting at the 26 character, it will return the remaining 200. I chose 200 because you have different lengths of text in the cells. Don't worry, if there are fewer than 200 characters after the 25th, Excel won't add spaces or anything like that.
Daniel Turgel Dec 23, 2010 8:55 AM
Right Function
I have a column of text where the boxes have different numbers of characters. The first 25 characters in the each cell are dates and after that there are different numbers of characters in each cell. So I'm trying to capture everything to the right of those first 25 characters, but I don't know how to do this because there are a different number of characters in each cell - is there a function in excel that can do this?
 
blog comments powered by Disqus
Email to a friend