Read Excel Tips Such As How To Use Functions To Isolate Everything After A Dash In A Column At BrightHub.com
RSS
 View all Hubs
See what's in...

Microsoft Excel: How To Use Functions To Isolate Everything After A Dash In A Column

Article by Mr Excel (11,376 pts )
Published on Jun 24, 2008
Problem: A vendor file contains a three-segment part number, as shown in Fig. 276. Each segment is separated by a dash. The length of each segment could be any number of characters. Find the second or third segment.
14 views

See all Microsoft Excel tips

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 all Microsoft Excel tips

Images

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

Bright Hub - Science & Technology Articles, Buyer's Guides, How-To Tips and Software Reviews
About Bright Hub | Contact Us | Terms of Use | Privacy Policy | Copyright Policy | ©2008 Bright Hub Inc. All rights reserved. Page copy protected against web site content infringement by Copyscape