LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Numbers vs Values

On Tue, 05 Apr 2005 18:57:00 -0700, "keepITcool" wrote:

ron
12.1 and 12,1 will not give similar outcome with your udf.


It will if the inputs are both numeric, but not if text.

That's why I wrote:

"If the contents is the number 12,2 it will return 12,2 also. But if the
contents is the text string 12.2, the function will return the number 122,0"


i tried following and that seems to do the job, both for commas and
dots.


Function GetVal(rng As Range)
Dim vIn, sDec$

vIn = rng
sDec = Application.International(xlDecimalSeparator)

If sDec < "." And InStr(vIn, sDec) 0 Then
vIn = Application.Substitute(vIn, sDec, ".")
End If
GetVal = Val(vIn)

End Function


Both give somewhat inconsistent results depending on the input and regional
settings.

For example, given English(US) settings and all inputs as text:

Input Yours Mine
12.2a 12.2 12.2
12,2a 12 12
12.2 12.2 12.2
12,2 12 122

If the inputs are numeric, both should give accurate results.

That is why we need more information from the OP in order to come up with a
bulletproof scheme.


--ron


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count numbers and non numbers(conditional values) Ecoman Excel Discussion (Misc queries) 5 May 9th 08 04:56 PM
Sum in numbers for text values asgh77 New Users to Excel 4 July 25th 06 03:49 PM
can numbers be assigned to values, replacing values for numbers Cossloffe Excel Discussion (Misc queries) 2 June 3rd 06 10:22 AM
Combo Box Values not Numbers Doyle Brunson Excel Worksheet Functions 8 August 17th 05 01:40 PM
Getting top 5 values in a list of numbers Roel Excel Programming 1 March 10th 05 02:03 AM


All times are GMT +1. The time now is 12:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"