Return value from text line
-
- GoldLounger
- Posts: 2628
- Joined: 26 Jan 2010, 16:31
- Location: Southern California
Return value from text line
Is it possible to return a value from a text line using a "Find or Search" function? Text to column does not work as the overall length changes with each record and the only delimiter is a blank space.
Example:
02/27 AMAZON MKTPLACE PMTS AMAZON MKTPLA WA 123.45
02/24 Amazon.com AMZN.COM/BILL WA 9.87
Example:
02/27 AMAZON MKTPLACE PMTS AMAZON MKTPLA WA 123.45
02/24 Amazon.com AMZN.COM/BILL WA 9.87
Regards,
John
John
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- GoldLounger
- Posts: 2628
- Joined: 26 Jan 2010, 16:31
- Location: Southern California
Re: Return value from text line
Hans,
The value in each record. In the two examples: 123.45 and 9.87
The value in each record. In the two examples: 123.45 and 9.87
Regards,
John
John
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Return value from text line
Let's say the first text is in A1.
Enter the following formula in B1, then fill down.
=--TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",255),LEN(A1)-LEN(SUBSTITUTE(A1," ",""))),255))
Enter the following formula in B1, then fill down.
=--TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",255),LEN(A1)-LEN(SUBSTITUTE(A1," ",""))),255))
Best wishes,
Hans
Hans
-
- GoldLounger
- Posts: 2628
- Joined: 26 Jan 2010, 16:31
- Location: Southern California
-
- 4StarLounger
- Posts: 574
- Joined: 14 Nov 2012, 16:06
Re: Return value from text line
A UDF:
in cell C1: =F_snb(A1)
Code: Select all
Function F_snb(c00)
F_snb=filter(split(c00),".")(0)
End Function
-
- 5StarLounger
- Posts: 964
- Joined: 08 Nov 2012, 17:54
Re: Return value from text line
@snb...
How would that work for both a dot and comma decimal delimiter if you were unsure of where the data was coming from... And then there's a dot for date delimiter as well in for example Germany as was pointed out by Alan in another thread???
Lisa
How would that work for both a dot and comma decimal delimiter if you were unsure of where the data was coming from... And then there's a dot for date delimiter as well in for example Germany as was pointed out by Alan in another thread???
Lisa
-
- 4StarLounger
- Posts: 574
- Joined: 14 Nov 2012, 16:06
Re: Return value from text line
If you are unsure you'd better keep far from VBA.....
-
- 5StarLounger
- Posts: 964
- Joined: 08 Nov 2012, 17:54
Re: Return value from text line
With respect... I think you've misinterpreted my post snb.
The point of it was that depending on a dot being in the string in the right place is precarious at best and wrong at worst.
The number at the end may not even contain a decimal delimiter at all but may be an integer such as 1 or 2 or even 177743.
Lisa
The point of it was that depending on a dot being in the string in the right place is precarious at best and wrong at worst.
The number at the end may not even contain a decimal delimiter at all but may be an integer such as 1 or 2 or even 177743.
Lisa
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Return value from text line
Lisa, here is a version that works in the situations you mention:
Code: Select all
Function F_snb(c00)
Dim a() As String
a = Split(c00)
F_snb = Val(a(UBound(a)))
End Function
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 964
- Joined: 08 Nov 2012, 17:54
Re: Return value from text line
That's great... thank you Hans!
An improvement indeed!
I could be wrong... but I think though, ISO rules for numbers, include a space for "thousands" .. not sure about that.. going to look that up now.
Lisa
An improvement indeed!
I could be wrong... but I think though, ISO rules for numbers, include a space for "thousands" .. not sure about that.. going to look that up now.
Lisa
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Return value from text line
Numbers with spaces will be more difficult to handle.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 964
- Joined: 08 Nov 2012, 17:54
Re: Return value from text line
It appears that I was wrong. The international standard for number formats does not appear to be standard at all.
From a *brief* search.. it seems that a comma OR a dot can be used as a decimal delimiter.
Also... America uses a comma as a thousands delimiter while some others use a dot.
An example is ...
Slovak Euro 12 345 678,00 €
Using an atypical for continental Europe, dot for the decimal and a "thin space" whatever that is.. for thousands delimiter.
It would be nice if everyone made some decision about this but I feel that's a long way off!!!!
I wonder what a truly international function would look like to return a "standard" number format. I think it may be quite big. Perhaps a REGEX expression would help.
Lisa
From a *brief* search.. it seems that a comma OR a dot can be used as a decimal delimiter.
Also... America uses a comma as a thousands delimiter while some others use a dot.
An example is ...
Slovak Euro 12 345 678,00 €
Using an atypical for continental Europe, dot for the decimal and a "thin space" whatever that is.. for thousands delimiter.
It would be nice if everyone made some decision about this but I feel that's a long way off!!!!
I wonder what a truly international function would look like to return a "standard" number format. I think it may be quite big. Perhaps a REGEX expression would help.
Lisa
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Return value from text line
From ISO 31-0:
To expand snb's function to take all kinds of formatted numbers into account would be a lot of work; I don't think we need to do that in this thread.Numbers consisting of long sequences of digits can be made more readable by separating them into groups, preferably groups of three, separated by a small space. For this reason, ISO 31-0 specifies that such groups of digits should never be separated by a comma or point, as these are reserved for use as the decimal sign.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 964
- Joined: 08 Nov 2012, 17:54
Re: Return value from text line
Agree... thank you Hans.