Not sure if formula or VBA will do this Extracting from Text: F123456, A123456

chipgiii

Board Regular
Joined
Nov 24, 2008
Messages
137
I would like to extract from text. I am trying to find a way to extract from text a string that starts with the letters A, C, or F and is followed by six numbers:

F123456
C654321
A345621

the cells often look like, the below three examples with the text in red what I would like to extract. Not sure if this is doable, but help is welcomed.

CR F319181 FY19-MAY18-51990-L
C 8500078841 FCR F316684 UPH

8500078841FCR A316684 UPHS


 

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
5,146
Hi,

Based on your given samples, here's one way:

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style=";">CR F319181 FY19-MAY18-51990-L</td><td style=";">F319181</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style=";">C 8500078841 FCR F316684 UPH</td><td style=";">F316684</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style=";">8500078841FCR B316684 UPHS</td><td style=";"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style=";">8500078841FCR A316684 UPHS</td><td style=";">A316684</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">5</td><td style=";">C123456 7890123 ABCDEF</td><td style=";">C123456</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">6</td><td style=";">789012 ABCDEF C123456</td><td style=";">C123456</td></tr></tbody></table><p style="width:6.4em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet483</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">B1</th><td style="text-align:left">=IFERROR(<font color="Blue">TRIM(<font color="Red">MID(<font color="Green">A1,LOOKUP(<font color="Purple">LEN(<font color="Teal">A1</font>),SEARCH(<font color="Teal">{" A?????? "," C?????? "," F?????? "}," "&A1&" "</font>)</font>),8</font>)</font>),""</font>)</td></tr></tbody></table></td></tr></table><br />

Formula copied down.
 

chipgiii

Board Regular
Joined
Nov 24, 2008
Messages
137
Hi,

Based on your given samples, here's one way:

AB
1CR F319181 FY19-MAY18-51990-LF319181
2C 8500078841 FCR F316684 UPHF316684
38500078841FCR B316684 UPHS
48500078841FCR A316684 UPHSA316684
5C123456 7890123 ABCDEFC123456
6789012 ABCDEF C123456C123456

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet483

Worksheet Formulas
CellFormula
B1=IFERROR(TRIM(MID(A1,LOOKUP(LEN(A1),SEARCH({" A?????? "," C?????? "," F?????? "}," "&A1&" ")),8)),"")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>



Formula copied down.
This is working very well, very, very well!

Thanks!!!!
 

Watch MrExcel Video

Forum statistics

Threads
1,098,992
Messages
5,465,869
Members
406,452
Latest member
GroupGoal

This Week's Hot Topics

Top