Extract Text using one formula

pto160

Active Member
Joined
Feb 1, 2009
Messages
478
Office Version
  1. 365
Platform
  1. Windows
I have the latest version of Excel 365 with all the new functions. :) so I am wondering if extracting text will be easier.
So if cell in column A says "Bank" then the result returned will be the text in column B.
There is two scenarios with the cell named GL in column A where the text string begins with an A. The max length of the text string allowed is 10 characters.
First scenario, is text beginning with a "A" then yymmdd then the last 3 characters reserved for a number. If the last three characters are a number like for example 005 or 010 or 400 then the result returned will be 5, 10 or 400 returned in column C.
The next scenario, If the last character or last two characters are a letter like B or AC, then the text is formatted beginning with an A then mmddyy then the number then the letter or two letters at the end. If the string ends with a two letters like "AC", then I can't use 02 for the month as it would exceed 10 characters. I have to use 2 for the month. The example will makes this clearer.

Book1
ABCD
1Result I want
2Bank55 Text Length
3GLA221228005510
4GLA2212280101010
5GLA22122840040010
6GLA12282201A110
7GLA12282202A210
8GLA1228222AC210
9GLA12282210A1010
Sheet1
Cell Formulas
RangeFormula
C2C2=IF(A2="Bank",B2)
D3:D9D3=LEN(B3)
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Is this what you are after?

23 01 05.xlsm
ABC
1Result I want
2Bank55
3GLA2212280055
4GLA22122801010
5GLA221228400400
6GLA12282201A1
7GLA12282202A2
8GLA1228222AC2
9GLA12282210A10
Extract
Cell Formulas
RangeFormula
C2:C9C2=IF(A2="Bank",B2,IF(ISNUMBER(RIGHT(B2,1)+0),RIGHT(B2,3)+0,MID(B2,8,1+ISNUMBER(MID(B2,9,1)+0))+0))
 
Upvote 0
Or try

Book1
ABC
1Result I want
2Bank55
3GLA2212280055
4GLA22122801010
5GLA221228400400
6GLA12282201A1
7GLA12282202A2
8GLA1228222AC2
9GLA12282210A10
Sheet1
Cell Formulas
RangeFormula
C2:C9C2=LOOKUP(999,--LEFT(RIGHT(B2,3),{1,2,3}))
 
Upvote 0
Try,
Excel Formula:
=IF(A2="Bank",B2,VALUE(TEXTJOIN("",TRUE,IF(ISNUMBER(MID(B2,{8,9,10},1)+0),MID(B2,{8,9,10},1)+0,""))))
 
Upvote 0
Another option
Fluff.xlsm
ABC
1Result I want
2Bank55
3GLA2212280055
4GLA22122801010
5GLA221228400400
6GLA12282201A1
7GLA12282202A2
8GLA1228222AC2
9GLA12282210A10
Data
Cell Formulas
RangeFormula
C2:C9C2=IF(A2="Bank",B2,TEXTBEFORE(RIGHT(B2,3),CHAR(SEQUENCE(,26,65)),,,1)+0)
 
Upvote 0
Thanks so much to everyone. These solutions are absolutely fantastic. This is going to save me so much time. :) :cool:(y)
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
I am not sure if I need to set up a new thread but the data stays the same. In column D, I would like to see if the last character or 2nd last last character ends in for example A or AC then it is text otherwise it is a number.
Book1
ABCD
1Result I wantIs Text
2Bank55No
3GLA2212280055No
4GLA22122801010No
5GLA221228400400No
6GLA12282201A1Yes
7GLA12282202A2Yes
8GLA1228222AC2Yes
9GLA12282210A10Yes
10GLA12282210BA10Yes
Sheet1
 
Upvote 0
Try

Book5
ABCDE
1Result I wantIs Text
2Bank55No
3GLA2212280055No
4GLA22122801010No
5GLA221228400400No
6GLA12282201A1Yes
7GLA12282202A2Yes
8GLA1228222AC2Yes
9GLA12282210A10Yes
10GLA12282210BA10Yes
11
12
Sheet1
Cell Formulas
RangeFormula
D2:D10D2=IF(ISNUMBER(RIGHT(B2)+0),"No","Yes")
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,198
Members
449,072
Latest member
DW Draft

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