ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Populating Third Dimesion Based on Average of three elements of Third Dimension (https://www.excelbanter.com/excel-programming/290133-populating-third-dimesion-based-average-three-elements-third-dimension.html)

ExcelMonkey[_67_]

Populating Third Dimesion Based on Average of three elements of Third Dimension
 
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

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Populating Third Dimesion Based on Average of three elements of Third Dimension
 
Sub Thing()
Dim Array1() As Variant
Dim X As Integer
Dim Y As Integer
Dim Z As Integer
Dim tot as Single
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 X = 1 To 4
For Y = 1 To 3
tot = 0
For Z = 1 To 3
Array1(X, Y, Z) = Rnd()
tot = tot + array1(X,Y,Z)
Next Z
if Tot/3 < .5 then
array1(x,y,4) = rnd()
array1(x,y,5) = "?" ' you didn't say what to set it to
else
array1(x,y,4) = 0
array1(x,y,5) = 0
End if
Next Y
Next X

End Sub

--
Regards,
Tom Ogilvy


"ExcelMonkey " wrote in message
...
I have a 3D array I populate the first and second dimension with random
numbers (i.e. all rows and columns). I continue doing this into the
third element of the third dimension. For the 4th and 5th elements of
the third dimsions I only want to populate the rows and columns if a
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 want
to average across the 3rd dimension for the rows and columns. This
would be tantamount to averaging specific cells across three different
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 elements
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 Z


---
Message posted from http://www.ExcelForum.com/




Sonny Kocak

Populating Third Dimesion Based on Average of three elements of Third Dimension
 
Hello Tom,

Thank you for answering this issue.

Issue resolved by community.

Sonny Kocak

Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: "Tom Ogilvy"
| References:
| Subject: Populating Third Dimesion Based on Average of three elements
of Third Dimension
| Date: Tue, 3 Feb 2004 16:27:46 -0500
| Lines: 85
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID:
| Newsgroups: microsoft.public.excel.programming
| NNTP-Posting-Host: host-141-116-172-231.ptr.hqda.pentagon.mil
141.116.172.231
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA05.phx.gbl!TK2MSFTNGP08
..phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa07.phx.gbl microsoft.public.excel.programming:458999
| X-Tomcat-NG: microsoft.public.excel.programming
|
| Sub Thing()
| Dim Array1() As Variant
| Dim X As Integer
| Dim Y As Integer
| Dim Z As Integer
| Dim tot as Single
| 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 X = 1 To 4
| For Y = 1 To 3
| tot = 0
| For Z = 1 To 3
| Array1(X, Y, Z) = Rnd()
| tot = tot + array1(X,Y,Z)
| Next Z
| if Tot/3 < .5 then
| array1(x,y,4) = rnd()
| array1(x,y,5) = "?" ' you didn't say what to set it to
| else
| array1(x,y,4) = 0
| array1(x,y,5) = 0
| End if
| Next Y
| Next X
|
| End Sub
|
| --
| Regards,
| Tom Ogilvy
|
|
| "ExcelMonkey " wrote in
message
| ...
| I have a 3D array I populate the first and second dimension with random
| numbers (i.e. all rows and columns). I continue doing this into the
| third element of the third dimension. For the 4th and 5th elements of
| the third dimsions I only want to populate the rows and columns if a
| 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 want
| to average across the 3rd dimension for the rows and columns. This
| would be tantamount to averaging specific cells across three different
| 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 elements
| 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 Z
|
|
| ---
| Message posted from
http://www.ExcelForum.com/
|
|
|
|



All times are GMT +1. The time now is 11:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com