• Excel Book Excerpt

Excel How to Isolate the Center Portion of an Account ID

This page is an advertiser-supported excerpt of the book, Learn Excel 2007-2010 from MrExcel - 512 Excel Mysteries Solved. If you like this topic, please consider buying the entire e-book.

How to Isolate
the Center Portion of an Account ID

Problem: My company assigns an account ID in the format SSS-XX-YYYY. I need to isolate the XX portion of the account ID in order to subtotal or sort the data.

LE10000200.jpg 

Figure 229 Use a formula to extract the middle of the account ID.

Strategy: You can insert a new column and use the MID function to isolate the necessary digits from the Account field.

The MID function takes three arguments: (1) a cell that contains a text value, (2) the character number where you want the result to start, and (3) the length of the result.

In a well-formed account number, such as 123-45-6789, you can predict that the start of the second segment will always be in the fifth character position and the length of the second segment is always two characters. Therefore, you can follow these steps:

1. In a blank column, such as column G, enter a heading such as Key.

2. In cell G2, enter the formula =MID(A2,5,2).

3. Copy the formula down to all rows.

LE10000201.jpg

Figure 230 Get the middle text, starting at position 5, for a length of 2.

Additional Details: In order to capture the final four digits of the account number, you could either use =MID(A2,8,4) or =RIGHT(A2,4).

Results: You can now sort by the new column and add subtotals based on the Account field.

<-Previous Topic Next Topic->

For more resources for Microsoft Excel:

privacy policy