I am using the following code in a macro to simply write data to an array and then output the results to a worksheet.
The array seems to take in the data correctly, but instead of outputting 0, .5, 1, 1.5, etc., the result is:
0.5
0.5
1
2.5
2.5
2.5
3
4.5
4.5
4.5
5
Can anyone tell me why this is happening? Thank you so much!
Code:
Sub test()
Dim Arr(0 To 5) As Double, row As Integer
Dim i As Double
row = 1
For i = 0 To 5 Step 0.5
Arr(i) = i
Next i
For i = 0 To 5 Step 0.5
Cells(row, 1).Value = Arr(i)
row = row + 1
Next i
End Sub
The array seems to take in the data correctly, but instead of outputting 0, .5, 1, 1.5, etc., the result is:
0.5
0.5
1
2.5
2.5
2.5
3
4.5
4.5
4.5
5
Can anyone tell me why this is happening? Thank you so much!