Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I split/parse a string around the first number in Excel

I have a string in column A that is a mixture of letters and numbers. I want to split the string in half before the first number that shows up such that "abc123" becomes "abc" in column B and "123" in column C.

like image 332
phan Avatar asked Feb 27 '13 15:02

phan


People also ask

How do I extract the first number from a string in Excel?

Extract first n characters from string Select a blank cell, here I select the Cell G1, and type this formula =LEFT(E1,3) (E1 is the cell you want to extract the first 3 characters from), press Enter button, and drag fill handle to the range you want. Then you see the first 3 characters are extracted.

How do I split text and numbers into separate cells?

Select the cells you want to divide, navigate to the Data tab > Data Tools group, and click the Text to Columns button. In the first step of the Convert Text to Columns wizard, you choose how to split cells - by delimiter or width.


1 Answers

If there's any sort of pattern, e.g. always 3 letters.....or only 3 or 4 letters, for example then you can achieve more easily but for any number of letters (assuming that numbers always follow letters) you can use this formula in B2 (which is simpler than the suggested formula in topcat3's link, I think)

=LEFT(A2,MIN(FIND({1,2,3,4,5,6,7,8,9,0},A2&1234567890))-1)

and then this formula in C2

=REPLACE(A2,1,LEN(B2),"")

Note that this last formula returns the number part as a text value - if you want it to be numeric add +0 to end of formula (but you will lose any leading zeroes)

like image 117
barry houdini Avatar answered Nov 15 '22 09:11

barry houdini