formula to extract numbers

RPrasad

Board Regular
Joined
Mar 22, 2008
Messages
144
Hi,

My data in one column "Name" looks like this
Travel Eur 02-09 for 128789

Earlier there were only 4 digits at the end and I was using the below expression to get the numbers into another column. Now the number of digits vary, and I need only the numbers in another column. These numbers will be always at the end.
Code:
Right(TravelSAP!Name,4)

please help me to put the formula to extract the number part from the last irrespective of number of characters.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Code:
SELECT 
[Name],
mid( [Name], instrrev ([Name], "for ") + 4)
FROM your_table
as long as the chars are preceeded by
"for "
it should work
 
Last edited:
Upvote 0
James,
only numbers at the end remains constant, not the explanation prior to that. And I need to extract full part of the numbers i.e. 128789, in another line it could be 12878 etc. "for" is not constant which may not be available in all the lines.
 
Upvote 0
so the numbes always appear at the end ?
and is there always a space before the numbes ?
is so, just search for a space instead of for "for "
Code:
SELECT 
[Name],
mid( [Name], instrrev ([Name], " ") + 1)
FROM your_table
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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