Listing out 5 characters after certain string?

JV63

New Member
Joined
Sep 30, 2009
Messages
44
Hi. I have a string for example like this:

[TABLE="width: 643"]
<tbody>[TR]
[TD="width: 643"]AT R05DD84100TL DAAIA84100OT01A1ZTM DGMFL00991

I want to be able to list out only the 5 characters after "OT". So in the above example it would be 01A1Z.

I can do that in two different cells using:

=MID(A2,FIND("OT",A2)+2,LEN(A2)) which gives me: [TABLE="width: 389"]
<tbody>[TR]
[TD="class: xl66, width: 389"]
01A1ZTM DGMFL00991[/TD]
[/TR]
</tbody>[/TABLE]

And then using:

=LEFT(B2,5) which will give me the 01A1Z

Is there a way to combine those functions or use something different which will give me what I need in one formula?

The OT that I'm looking for isn't always in the same spot of a string. In can be for example:

[TABLE="width: 643"]
<colgroup><col></colgroup><tbody>[TR]
[TD]AT R05DD84100TL DAAIA84100OT01A1ZTM DGMFL00991

[/TD]
[/TR]
[TR]
[TD]ATA02A1DD05100TL AAATM ACAOT03A2CIA05100[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]ATA02A2DD05300TL DCATM DGBNB OT03A2MNC FF IA05300

Thanks[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
You virtually had it. Instead of using LEN(A2) use 5.

=MID(A2,FIND("OT",A2)+2,5)
 
Upvote 0
Try this.

=MID(A2, FIND("OT",A2)+2,5)
 
Upvote 0
There are simpler options (as shown above), but you have already pretty much done all the work!
Just subsititute your first formula into your second, i.e.
=LEFT(MID(A2,FIND("OT",A2)+2,LEN(A2)),5)
 
Last edited:
Upvote 0
Thanks everyone for the quick replies. I was close :)

=MID(A2,FIND("OT",A2)+2,5) worked perfectly.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top