The following function will take a range argument and store the values in its
cells in an array. Please note that if you declare the array within the
function, it ceases to exist when the function ends.
Option Explicit
Dim Trate() As Double, MaxIdx As Long
Sub AAAAA()
Dim n As Long
If Rng2Array(Selection) Then
For n& = 1 To MaxIdx&
MsgBox Trate(n&)
Next n&
End If
End Sub
Function Rng2Array(Rng As Range) As Boolean
Dim c As Range
On Error GoTo R2Aerr
ReDim Trate(Rng.Cells.Count)
MaxIdx& = 0
For Each c In Rng
MaxIdx& = MaxIdx& + 1
Trate(MaxIdx&) = c.Value
Next c
Rng2Array = True
Exit Function
R2Aerr:
Rng2Array = False
End Function