Extract numbers - exact values?

ljubo_gr

Board Regular
Joined
Dec 6, 2014
Messages
244
Office Version
  1. 2016
Platform
  1. Windows
Hello dear MrExcel's

How to extract value from right, from an aray of data?


CMR: 30.501 litres, rest 11.000 for Barack Obama.
Cmr:31.700L but 5000 goes from R-7 to John Kerry.
cmr: 30000 L rest goes 500 to WhiteHouse from R-7

<tbody>
</tbody>

tHESE are only three examples, three rows of data, they are different but simmilar, How to extract 11000 5000 and 500 and Sum that?
This is impossible 'cause they are different, one start with "rest 11000", second starts with "but", third with "goes"....If i extract numbers i get 3050111000 3170050007......
Any help would be kindly appreciated, Thanks!
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
I dont think youll be able to do this smoothly, as you impossible as there's no pattern.
You could may be extract the rightmost number from the strings that would give you 11.000 5000 and 500 but it depends what youre other data is like.
 
Upvote 0
You could may be extract the rightmost number from the strings that would give you 11.000 5000 and 500 ...
Not by my reckoning. It appears to me that the right-most numbers would be
11.000
7
7

or
11.000
-7
-7
 
Upvote 0
With such a small dataset.. it is impossible to extract any kind of legitimately recurring dataflow (that can be split/counted etc)

With 3 lines as an example.. who would know?
 
Last edited:
Upvote 0
Try this formula before get the numbers from string:

=SUBSTITUTE(SUBSTITUTE(A6,LEFT(A6,12),""),"R-7","")

Note that with this formula, the number that you want must be always after the 12º caracter of the string.
 
Last edited:
Upvote 0
Not by my reckoning. It appears to me that the right-most numbers would be
11.000
7
7

or
11.000
-7
-7

R-7 is not a number.
I thiought common sense would indicate what I was aiming at.

Based on your -7 assumption

11.000 is not the right most number, the right most number is in fact 0

11.000
 
Last edited:
Upvote 0
Hi

You have to give a stronger specification. Like Peter said, the last number is not what you want.

Can you say, for ex. that it's the last number preceded and followed by a space?
 
Upvote 0
R-7 is not a number.
I didn't suggest that it was. I did suggest that 7 and -7 are numbers.


Based on your -7 assumption

11.000 is not the right most number, the right most number is in fact 0
That would be the right-most digit by my reckoning. In general, a number is made up of 1 or more digits (& possibly decimal points, negative signs, exponents etc)

Rather than quoting your post, perhaps I should have quoted the OP's post which also described the requirement as "extract value from right". I'm sorry if I offended you.

Most likely the requirement is as pgc has described and you have assumed. I was just pointing out the ambiguity.
 
Upvote 0
I just need to: hhmmm:confused: My number will always be between CMR:30000litres (30000) and R-7(5to12 designations), so, first i have to find Left that CMR number, then right if exist that R- number, in between is my number. If there isn't R- number then my number will always be smaller than big CMR number. So formula must be so complex. I'm using excel2013. Thank you so much for your timE! I forgot, space" " is between numbers, always.
 
Last edited:
Upvote 0
Hi

This is a solution with these 2 assumptions:
- you want the last integer between spaces
- your integer may have thousand separators that are "."

Try this udf:

Code:
Function GetNumber(s As String) As Long

With CreateObject("VBScript.RegExp")
    .Pattern = ".* (\d+(\.\d{3})*) .*"
    GetNumber = Replace(.Replace(s, "$1"), ".", "")
End With
End Function

In B1: =GetNumber(A1)
Copy down
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,323
Members
449,077
Latest member
jmsotelo

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