I found one serious one myself, when entering the last character in a
cell (”ö” in this case). The result was > 1 which is supposed to be
impossible.
The mistake was of the embarrassing kind. I used the wrong length
value in the for loop (length of the sort order text instead of the
lenght of the input text)…
Here's my corrected cell function:
Option Explicit
Function SortValue(sText As String)
Dim sSorted As String
sSorted="0123456789abcdefghijklmnopqrstuvwxyzåäö"
Dim iLenSorted As Integer, iLenText As Integer
iLenSorted=Len(sSorted)+1
iLenText=Len(sText)
Dim d As Double, i As Integer
Dim iFoundPos As Integer
sText=LCase(sText)
For i=1 To iLenText
iFoundPos=InStr(sSorted,Mid(sText,i,1))
If iFoundPos>0 Then
d=d+iFoundPos/iLenSorted^i
End If
Next i
SortValue=d
End Function
Also note that doing this text to number conversion is probably not a
good idea if the text contains too many characters and the first ones
are the same, like:
abcdefghijkl ⇨ 0,282708744247206000
abcdefghijlk ⇨ 0,282708744247206000
So in many cases, this method should not be used. See my example file
(which I modified since last time) at:
http://ubuntuone.com/1I7EY6jMoZ4MYLrPejP5Eh
The next suggestion would probably be to create a cell function that
replaces the SMALL() function and works with text.
Maybe I will try that later, I don't know. Or perhaps someone else
will beat me to it.
Johnny Rosenberg