Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Michael,
Your function simplified =testfunc2(A1:A10) Function testfunc2(rng As Range) As Double Dim r As Variant Dim arr As Variant Dim x As Integer For x = 1 To rng.Count Debug.Print rng.Item(x).Value Debug.Print rng.Item(x).Address Next x End Function Mike "Michael" wrote: On Mar 3, 2:00 pm, Michael wrote: I am looking for an example of how to pass a function a range and assign it to an array so I can access the values with an index number. For some reason I cant get this to work. Forgot to indclude example Function testfunc2(rng As Range) Dim r As Variant Dim arr As Variant Dim x As Integer 'arr = rng 'assign range values to array For Each r In rng arr(x) = r.Value x = x + 1 Next 'list array values For x = LBound(arr) To UBound(arr) Debug.Print arr(x).Value Next x testfunc2 = "test" End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Assign a 2D array of constant values to a range | Excel Programming | |||
Excel 2003. Assign array to range | Excel Programming | |||
Translate range name passed as string to a custom function to range addresses! | Excel Programming | |||
Error Converting Passed Range into Array in VBA for Excel | Excel Programming | |||
Error Converting Passed Range into Array in VBA for Excel | Excel Programming |