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

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

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,095,198
Messages
5,442,987
Members
405,212
Latest member
Arnie58

This Week's Hot Topics

  • Copy entire row if CountA <>0 to another sheet
    [B]I want to copy entire row if CountA <>0 for column J7:AM7 (headers on J6:AM6) and so on till the last used cell is column D and paste the...
  • Select last used Row in Table
    I have created a Table in a Worksheet which is locked to prevent user errors and protect formula. Some of the cells require freetext entries which...
  • excel workbook: do not allow certain file name
    Hello all, Don't think this has ever been asked before, but how do I restrict file save [Before_Save Event] if the name of the file being saved...
  • fixing problem autofilter
    hello i need help about my code when i search by code in textbox it doesn't show anything this is my data [ATTACH type="full"...
  • “Weight”
    Hi, i’ve got a long sheet filled with weights such as kg,g,L & ml. i can build a formula to convert kg into g and liter into ml. How ever, my...
  • How to capitalize everything before a certain character?
    In column A, I have some text: Hello good day.mp3 Hello good day.flac etc. I'd like to capitalize everything before the period. I don't need the...
Top