![]() |
Passing array to a function
AAA=ExactMatch ( Guess(1,) )
The above does not work, needless to say. ExactMatch is a function expecting to receive a single dimensional array Guess is a 2-dimensional array. What I am attempting to do is pass the 1st row of Guess to the function. What is the correct syntax to do that, please? (Obviously, I can be more explicit about what I am passing across, but I thought VBA would take care of this for me.) Thanks Geoff |
Passing array to a function
There is no automatic way in VBA to do this.
Since you are using VBA in Excel, you can use the Excel Index function Sub Tester2() Dim myArray(1 To 6, 1 To 2) For i = 1 To 6 For j = 1 To 2 myArray(i, j) = Chr(i * j + 64) Next j Next i varr = Application.Index(myArray, 0, 2) For i = LBound(varr) To UBound(varr) Debug.Print i, varr(i, 1), myArray(i, 1), myArray(i, 2) Next End Sub This returns the second column of a 2D array - but it returns it as 1 x Number of rows, 1 x 1 -- Regards, Tom Ogilvy GB wrote in message ... AAA=ExactMatch ( Guess(1,) ) The above does not work, needless to say. ExactMatch is a function expecting to receive a single dimensional array Guess is a 2-dimensional array. What I am attempting to do is pass the 1st row of Guess to the function. What is the correct syntax to do that, please? (Obviously, I can be more explicit about what I am passing across, but I thought VBA would take care of this for me.) Thanks Geoff |
Passing array to a function
Thanks Tom and Dave. I guess I was looking for something that does not exist
in VBA. I had not thought of using Application.Index, but I can see that that would shorten my code. Thanks again. Geoff |
All times are GMT +1. The time now is 09:45 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com