E
ExcelMonkey
I have a 3D array I populate the first and second dimension with rando
numbers (i.e. all rows and columns). I continue doing this into th
third element of the third dimension. For the 4th and 5th elements o
the third dimsions I only want to populate the rows and columns if
certain criteria is met. Otherwise make the value = 0.
(1,1,4) = Rnd() if the average of (1,1,1) to (1,1,3) is < .5 . I wan
to average across the 3rd dimension for the rows and columns. Thi
would be tantamount to averaging specific cells across three differen
sheets.
How do you do this?
Sub Thing()
Dim Array1() As Variant
Dim X As Integer
Dim Y As Integer
Dim Z As Integer
ReDim Array1(1 To 4, 1 To 3, 1 To 5)
'Populate 4 rows and 3 columns of top 3 layers with random numbers
For Z = 1 To 3
For X = 1 To 4
For Y = 1 To 3
Array1(X, Y, Z) = Rnd()
Next Y
Next X
Next Z
'Populuate remaining layers ( 4 and 5 )if the x values in 1-3 element
of third dimension Average<.5
For Z = 4 To 5
For X = 1 To 4
For Y = 1 To 3
If .........Then 'Average across
Array1(X, Y, Z) = Rnd()
Else
Array1(X, Y, Z) = 0
Next Y
Next X
Next
numbers (i.e. all rows and columns). I continue doing this into th
third element of the third dimension. For the 4th and 5th elements o
the third dimsions I only want to populate the rows and columns if
certain criteria is met. Otherwise make the value = 0.
(1,1,4) = Rnd() if the average of (1,1,1) to (1,1,3) is < .5 . I wan
to average across the 3rd dimension for the rows and columns. Thi
would be tantamount to averaging specific cells across three differen
sheets.
How do you do this?
Sub Thing()
Dim Array1() As Variant
Dim X As Integer
Dim Y As Integer
Dim Z As Integer
ReDim Array1(1 To 4, 1 To 3, 1 To 5)
'Populate 4 rows and 3 columns of top 3 layers with random numbers
For Z = 1 To 3
For X = 1 To 4
For Y = 1 To 3
Array1(X, Y, Z) = Rnd()
Next Y
Next X
Next Z
'Populuate remaining layers ( 4 and 5 )if the x values in 1-3 element
of third dimension Average<.5
For Z = 4 To 5
For X = 1 To 4
For Y = 1 To 3
If .........Then 'Average across
Array1(X, Y, Z) = Rnd()
Else
Array1(X, Y, Z) = 0
Next Y
Next X
Next