Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract the six digit number in a cell string?

I have a column with data:

New York is really nice, 456983 Good food
Beijing is awesome 678932, Nice culture.
... and so on

I want to extract the six digit numbers and place it in a column beside the original column.

There are n rows.

Is there any way to do this with a formula, without VBA?

like image 396
pan dong Avatar asked Oct 15 '25 03:10

pan dong


1 Answers

Without VBA, you can use the following Excel formula assuming A1 is the cell containing the text.

=MID(A1,FIND("------",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"0","-"),"1","-"),"2","-"),"3","-"),"4","-"),"5","-"),"6","-"),"7","-"),"8","-"),"9","-")),6)
like image 62
cbasah Avatar answered Oct 17 '25 18:10

cbasah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!