LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default PASSING an array to a sub in VBA

On Sun, 30 Nov 2003 05:22:33 -0600, Chip Pearson wrote:

Try using specific variable types in your array declaration and
the called function definition. For example, the following code
works in Excel 97 and Excel 2003.

Sub AAA()
Dim Arr(1 To 10) As Long
Dim Ndx As Long
For Ndx = 1 To 10
Arr(Ndx) = Ndx * 10
Next Ndx
BBB Arr()


I don't know about 97 or 2003, but in Excel 2000 the parentheses aren't
necessary - you can do it like this:
BBB Arr
and it works.

End Sub

Sub BBB(X() As Long)
Dim Ndx As Long
For Ndx = LBound(X) To UBound(X)
Debug.Print X(Ndx)
Next Ndx
End Sub


--
auric "underscore" "underscore" "at" hotmail "dot" com
*****
The Toe that can be stubbed is not the true Toe.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing string as array variable (Pivot VBA) klingongardener Excel Discussion (Misc queries) 2 December 23rd 06 07:58 PM
meaning of : IF(Switch; Average(array A, array B); array A) DXAT Excel Worksheet Functions 1 October 24th 06 06:11 PM
Passing a row to a function dch3 Excel Worksheet Functions 2 July 31st 06 12:34 PM
Passing array to a function GB[_3_] Excel Programming 3 October 21st 03 09:59 AM
Passing an Array of User-Defined Type to an Argument of a Function Tushar Mehta[_6_] Excel Programming 0 August 17th 03 06:43 PM


All times are GMT +1. The time now is 08:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"