Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Excel vba - passing a 3-dimensional array to a subroutine

as shown, the variable is defined as
dim variable as single

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Excel vba - passing a 3-dimensional array to a subroutine

Thanks, Tom!

You've shown me everything I needed.

Reply
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
Re : Excel Sorting a 2-Dimensional Array [email protected] Excel Programming 11 May 3rd 05 05:00 PM
Re : Excel Formulation of 2-Dimensional Array [email protected] Excel Programming 1 April 28th 05 02:54 PM
Excel Array Conversion from 2-Dimensional to One [email protected] Excel Programming 4 April 17th 05 10:05 AM
Create One-Dimensional Array from Two-Dimensional Array Stratuser Excel Programming 1 February 23rd 05 08:46 PM
Passing arrays to a subroutine Braden Craig Excel Programming 4 August 17th 03 05:54 PM


All times are GMT +1. The time now is 06:48 AM.

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

About Us

"It's about Microsoft Excel"