![]() |
Excel vba - passing a 3-dimensional array to a subroutine
Hello,
I'm having trouble getting the syntax right for passing a 3-dimensional array to a subroutine. The array in question in originally defined as dim variable() as single Later... ReDim variable(x,y,z) (through a series of For statements) and later still.... Subroutine is called (subroutine needs a specific component of array) A function would work for me as well. Hope someone can help... joran6 |
Excel vba - passing a 3-dimensional array to a subroutine
Hi joran6,
Try dimming the variable as "Dim Variable" instead and leave it as a Variant type. -- Regards, Zack Barresse, aka firefytr To email, remove NOSPAM wrote in message oups.com... Hello, I'm having trouble getting the syntax right for passing a 3-dimensional array to a subroutine. The array in question in originally defined as dim variable() as single Later... ReDim variable(x,y,z) (through a series of For statements) and later still.... Subroutine is called (subroutine needs a specific component of array) A function would work for me as well. Hope someone can help... joran6 |
Excel vba - passing a 3-dimensional array to a subroutine
as shown, the variable is defined as
dim variable as single |
Excel vba - passing a 3-dimensional array to a subroutine
Did you try the Variant like I showed? You could also try posting all of
your code. -- Regards, Zack Barresse, aka firefytr To email, remove NOSPAM wrote in message oups.com... as shown, the variable is defined as dim variable as single |
Excel vba - passing a 3-dimensional array to a subroutine
Sub Main()
Dim variable() As Single x = 10 y = 3 z = 3 ReDim variable(1 To x, 1 To y, 1 To z) For i = 1 To x For j = 1 To y For k = 1 To z variable(i, j, k) = i * j * k * Rnd() Next k, j, i Dummy variable End Sub Sub Dummy(v() As Single) MsgBox v(UBound(v, 1), UBound(v, 2), _ UBound(v, 3)) End Sub works fine for me as an illustration. What do you mean by needs a component? -- Regards, Tom Ogilvy " wrote: as shown, the variable is defined as dim variable as single |
Excel vba - passing a 3-dimensional array to a subroutine
Thanks, Tom!
You've shown me everything I needed. |
All times are GMT +1. The time now is 04:37 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com