Extract the last three numbers from a string

gloudy31

New Member
Joined
Jan 28, 2016
Messages
7
ACH 275F536CH
APA 275F542
SHB 080B530G
AOA 050N535-ACP

Say I have the 4 lot numbers listed above in cells A1 thru A4. In cells B1 thru B4 I want to extract the last 3 numbers from each string accordingly so it would appear as shown below.

536
542
530
535


Is there a formula or set of formulas that can accomplish this?

Thanks so much for your help!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hi All,

in the example you shared could do the trick:

=MID(A1,9,3)+0


Another approach using AGGREGATE

=MID(A1,AGGREGATE(14,6,ROW($1:$100)/ISNUMBER(MID(A1,ROW($1:$100),1)+0),1)-2,3)+0


For sure they are less robust than Tetra201's solution.
 
Last edited:
Upvote 0
@Tetra201 Your formula doesn't work for "APA 275F542".

Here's UDF which correctly works with all four examples:
Code:
Function GetNumber(cell)
    With CreateObject("VBScript.RegExp")
        .IgnoreCase = True: .Pattern = "(\d{3})-?[a-z]*$"
        With .Execute(cell)
            If .Count > 0 Then GetNumber = .Item(0).SubMatches(0) Else GetNumber = "Not Found"
        End With
    End With
End Function
 
Last edited:
Upvote 0
I didn't notice, but two numbers don't work out.
Here's proof:
tetra.png
 
Upvote 0
@Sektor:

Sorry, you are doing something wrong. Check if the formula is entered correctly.

Capture1.jpg


Capture2.jpg
 
Upvote 0

Forum statistics

Threads
1,215,007
Messages
6,122,670
Members
449,091
Latest member
peppernaut

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