Of course you are right, and many programmers prefer to avoid using
global/public variables. Passing the array as an argument, the code could be
rewritten:
Option Explicit
Sub AAAAA()
Dim n As Long, Trate() As Double
If Rng2Array(Selection, Trate()) Then
For n& = 1 To Selection.Cells.Count
MsgBox Trate(n&)
Next n&
End If
End Sub
Function Rng2Array(Rng As Range, InArray() As Double) As Boolean
Dim c As Range, x As Long
On Error GoTo R2Aerr
ReDim InArray(Rng.Cells.Count)
x& = 0
For Each c In Rng
x& = x& + 1
InArray(x&) = c.Value
Next c
Rng2Array = True
Exit Function
R2Aerr:
Rng2Array = False
End Function