Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Substring processing in Excel? 2

Status
Not open for further replies.

jimoblak

Instructor
Oct 23, 2001
3,620
US
I have a column that I need to break into two columns.

Can anyone explain a formula or method to get '12' and '34' into two columns out of '1234' in one column? Number positions 1 and 2 go in one column. Number positions 3 and 4 go in another column. ('1234' is example data. There are several thousand rows with varying 4 digit numbers)

CSV source example:
,1234,

CSV reult example:
,12,34,

 
Try the MID function.
i.e. If cell A1 contains "1234," and you want cell B1 to display 12, code it =MID(A1,1,2) and you'll get 12 displayed in cell B1. A1 position references the target cell or range, 1 represents your starting point in the target string, and 2 specs out how many characters you want to 'lop off.' This is a rather simple example, but you should be able to apply this to your range once you experiment with it.
In the Help documents, searching under MID returns other useful examples.
Good luck....
 
carrr's idea of using MID is a good one, [btw =LEFT(A1,2 and =RIGHT(A1,2)to separate the characters is another formula option] but if you're importing a csv file to excel you can specify the width of the column by selecting 'fixed width' on the import wizard. if you've already imported the file, you can use text to columns on the 'data' menu.
hth
schat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top