View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave Dave is offline
external usenet poster
 
Posts: 1,388
Default Declare and array in a function

I'm trying to declare an array from within a function, and then add to that
array certain fields from a range I use as the input variable. For example:

Function test(rng As Range)
valuesArr = rng
ReDim testArray(20) As String

For i = 1 To UBound(valuesArr)
testArray(i) = valuesArr(i, 1)
Next i
test = testArray(5)
End Function

So I want to add all values from within "rng" to "testArray()", and then
take the 5th element of testArray() and return it. I keep getting an error
when I enter the function, any ideas?
Thanks.