Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 3 dimensional array

I am trying to self learn vba and at this point I am dabbling with arrays. I
have a command button on sheet Array1 called cmd3dArray, also on this sheet
I have data a, b, c, etc in cells A1:E5. In the next sheet Array2 I have
data in A1:E5 namely a1, b1, c1 etc and similarly in sheet Array3, a2, b2
etc. I am trying to collect the data from the three sheets into a
3-dimensional array - I'm struggling - any offers.
Sandy


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 3 dimensional array

One way:

Option Explicit
Sub testme()
Dim wCtr As Long
Dim iCol As Long
Dim iRow As Long
Dim myArray(1 To 5, 1 To 5, 1 To 3) As Variant
'rows x cols x sheets

For wCtr = 1 To 3
For iRow = 1 To 5
For iCol = 1 To 5
myArray(iRow, iCol, wCtr) _
= Worksheets("array" & wCtr).Cells(iRow, iCol).value
Next iCol
Next iRow
Next wCtr

End Sub


Sandy wrote:

I am trying to self learn vba and at this point I am dabbling with arrays. I
have a command button on sheet Array1 called cmd3dArray, also on this sheet
I have data a, b, c, etc in cells A1:E5. In the next sheet Array2 I have
data in A1:E5 namely a1, b1, c1 etc and similarly in sheet Array3, a2, b2
etc. I am trying to collect the data from the three sheets into a
3-dimensional array - I'm struggling - any offers.
Sandy


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 3 dimensional array

I don't understand why you want a 3 dimentioned array. Perhaps a two
dimentioned array with the first index to indicate which of the 3 sheets:

Dim c, i
Dim MyArray(3, 25)

i = 0
For Each c In Worksheets("Array1").Range("A1:E5")
MyArray(1, i) = c
i = i + 1
Next c
i = 0
For Each c In Worksheets("Array2").Range("A1:E5")
MyArray(2, i) = c
i = i + 1
Next c
i = 0
For Each c In Worksheets("Array3").Range("A1:E5")
MyArray(2, i) = c
i = i + 1
Next c

"Sandy" wrote in message
...
....I have data a, b, c, etc in cells A1:E5. In the next sheet Array2 I have
data in A1:E5 namely a1, b1, c1 etc and similarly in sheet Array3, a2, b2
etc. I am trying to collect the data from the three sheets into a
3-dimensional array - I'm struggling - any offers.
Sandy


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
Create One-Dimensional Array from Two-Dimensional Array Stratuser Excel Programming 1 February 23rd 05 08:46 PM
Do I need a two dimensional array for this? hotherps[_17_] Excel Programming 1 February 20th 04 04:46 PM
add to two dimensional array GUS Excel Programming 1 August 26th 03 12:12 AM
2 Dimensional Array Tom Ogilvy Excel Programming 0 August 18th 03 08:04 PM
2 Dimensional Array steve Excel Programming 0 August 18th 03 07:19 PM


All times are GMT +1. The time now is 05:38 PM.

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"