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

chipgiii

Board Regular
Joined
Nov 24, 2008
Messages
136
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.

[TABLE="width: 454"]
[TR]
[TD="class: xl65, width: 454"]CR F319181 FY19-MAY18-51990-L[/TD]
[/TR]
[/TABLE]
[TABLE="width: 454"]
[TR]
[TD="class: xl65, width: 454"]C 8500078841 FCR F316684 UPH

[TABLE="width: 454"]
[TR]
[TD="class: xl65, width: 454"]8500078841FCR A316684 UPHS
[/TD]
[/TR]
[/TABLE]
[/TD]
[/TR]
[/TABLE]


 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi,

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


Book1
AB
1CR F319181 FY19-MAY18-51990-LF319181
2C 8500078841 FCR F316684 UPHF316684
38500078841FCR B316684 UPHS
48500078841FCR A316684 UPHSA316684
5C123456 7890123 ABCDEFC123456
6789012 ABCDEF C123456C123456
Sheet483
Cell Formulas
RangeFormula
B1=IFERROR(TRIM(MID(A1,LOOKUP(LEN(A1),SEARCH({" A?????? "," C?????? "," F?????? "}," "&A1&" ")),8)),"")


Formula copied down.
 
Upvote 0
Hi,

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

AB
CR F319181 FY19-MAY18-51990-LF319181
C 8500078841 FCR F316684 UPHF316684
8500078841FCR B316684 UPHS
8500078841FCR A316684 UPHSA316684
C123456 7890123 ABCDEFC123456
789012 ABCDEF C123456C123456

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: center"]2[/TD]

[TD="align: center"]3[/TD]

[TD="align: center"]4[/TD]

[TD="align: center"]5[/TD]

[TD="align: center"]6[/TD]

</tbody>
Sheet483

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]B1[/TH]
[TD="align: left"]=IFERROR(TRIM(MID(A1,LOOKUP(LEN(A1),SEARCH({" A?????? "," C?????? "," F?????? "}," "&A1&" ")),8)),"")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]



Formula copied down.

This is working very well, very, very well!

Thanks!!!!
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,198
Members
452,616
Latest member
intern444

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