Extract Last Number from String

Zakkaroo

Active Member
Joined
Jul 6, 2009
Messages
383
I have a column of information (see below for example). What I need as my output, is the LAST number in the string (i.e. the right most number)

Example:
[TABLE="width: 143"]
<tbody>[TR]
[TD]AB98 VUJ 94
[/TD]
[/TR]
[TR]
[TD]AB14 VUS 1247
[/TD]
[/TR]
[TR]
[TD]CD86 EVB 216
[/TD]
[/TR]
[TR]
[TD]AX26 EVD 122
[/TD]
[/TR]
[TR]
[TD]SA28 EVY 132
[/TD]
[/TR]
[TR]
[TD]SA26 NFN 6
[/TD]
[/TR]
[TR]
[TD]PQ13 NFT 779

Output:
94
1247
216
122
132
6
779

Any help much appreciated

[/TD]
[/TR]
</tbody>[/TABLE]

Edit: I realise it's possible to achieve this with Text to columns, but I really could do with a formula, as it's for a user, and I want to reduce the amount of manual work they need to do.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi,

You can use below formula if your number part will always start after 9th position.
=RIGHT(A1,LEN(A1)-9)

Regards,
Amitkumar J.
 
Upvote 0
Hi.

Since all your desired returns also happen to be the last delimited substring in the string:

=0+TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1)))

Regards
 
Upvote 0
A few more possibilities, depending on the circumstances.

1. If always starting after the 9th position as suggested by Amitkumar (and per all your samples), you can use a single function:
=REPLACE(A1,1,9,"")+0

2. If the number is always after the second space (as per all your samples) but perhaps not always the 10th place then
=REPLACE(A1,1,FIND(" ",A1,FIND(" ",A1)+1),"")+0

3. If there could be more or less than two spaces in the data but your number is always after the last space as solved by XOR LX you could use the marginally shorter
=0+RIGHT(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1))

4. And with the same circumstances as 3, unless you are expecting those "final numbers" to be extremely long you could save another couple of functions
=0+RIGHT(SUBSTITUTE(A1," ",REPT(" ",99)),99)
 
Upvote 0
3. If there could be more or less than two spaces in the data but your number is always after the last space as solved by XOR LX you could use the marginally shorter
=0+RIGHT(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1))

One day the message that you don't need to TRIM in such circumstances will finally get into my head! :)

Cheers
 
Upvote 0
One day the message that you don't need to TRIM in such circumstances will finally get into my head! :)

Cheers
He he, yes I think we shared this in another thread sometime in the last month or so. :)
 
Upvote 0

Forum statistics

Threads
1,225,468
Messages
6,185,162
Members
453,281
Latest member
shantor

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