How to returns a specific number of characters from a text string

Iron Contributor

I want to returns a specific number of characters from a text string

and I try to use MID and SEARCH formula for first row, but I dont know what to do next for other rows.
How can we get the expect result
Thank you




19 Replies




@Detlef Lewin 

Thank you for your response

when the first and at the end of text string added characters differently "x". It's show the result in column B



What exact logic shall be?

Remove specific character from the text;

Remove start of the text till first space;

Something else





@Sergei Baklan 

I want to separate the tracking number from the text string and its length11, 12 or 18 characters
sometimes it's at the beginning, middle or end of the string text

the expect result shown in column A



best response confirmed by littlevillage (Iron Contributor)


a,FILTERXML("<y><z>"&SUBSTITUTE(C2," ","</z><z>")&"</z></y>","//z"),


@Detlef Lewin 

Thank you

It is working perfectly, a little question please
Where have you create the formula?

@Detlef Lewin 

Hi Detlef,

Sorry for my english

I am just start with excel about 4 months

I mean, What did you use to write the formula?


@Detlef Lewin 



In regular excel I could not see something the same as this image, that's why I said' where did you write the formula"


That is due to the formatting of the forum editor.


@Detlef Lewin 

I see many member of this forum do it. How can I use it?

How do I ask questions here? Someone help me please. Where do I go to make posts?


on your right corner click it> go to Excel>Start a new Discussion




Open the full text editor and klick on "Insert code" in the icon bar.

TechCommunity Icon Bar.PNG


Then choose Language and enter the code.

TechCommunity Inaert Code.PNG

@Detlef Lewin 

sorry my friend, i am looking on google and youtube but i could not find how to open the full text Editor in excel.


That screenshot is not from Excel but from this forum.

In Excel you can expand the formula bar by pressing Ctrl+Shift+U.

And you can insert line breaks in a formula by pressing Alt+Enter.

@Hans Vogelaar 

yes, my friend,

I see 

Thank you