View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
hke[_24_] hke[_24_] is offline
external usenet poster
 
Posts: 1
Default loosing decimal upon sorting?


Hi all,
Hope someone can help with this problem

I use a dynamic array of Long type to keep som values in so that I ca
sort them later. The problem is that when I list the values afte
sorting them, the decimal value is lost; e.g 204,5 becomes 204,0 (al
values have a zero after the decimal point)

I do


Dim myArr() As Long

ReDim Preserve myArr(0 To counter)

myArr(counter) = _
Worksheets("Sheet1").Range("A" & counter).Value '

Call sort(myArr)

Then I use these algorithms to sort the values

Sub sort(A() As Long)
Dim i As Long, j As Long
For i = LBound(A) To UBound(A) - 1
For j = i + 1 To UBound(A)
If A(j) A(i) Then
swapI A(j), A(i)
End If
Next j
Next i
End Sub

Sub swapI(x As Long, y As Long)
Dim tmp As Long
tmp = x
x = y
y = tmp
End Sub

Can anyone help with this please

--
hk
-----------------------------------------------------------------------
hke's Profile: http://www.excelforum.com/member.php...nfo&userid=155
View this thread: http://www.excelforum.com/showthread.php?threadid=31931