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

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



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

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
Populating a cell based on a range of values akkrug New Users to Excel 2 June 20th 08 03:09 PM
Help with If-Then Statements/Populating Data based upon selection SK Excel Discussion (Misc queries) 1 April 13th 07 09:06 PM
Excel 2007 PivotTable "arbitrary shape is not allowed when its elements cross a reference dimension" Michael Excel Discussion (Misc queries) 0 July 20th 06 06:00 PM
Populating cells based on calculation Chris Excel Worksheet Functions 0 November 8th 04 01:22 PM
Combobox populating based on Option Button Todd Huttenstine[_2_] Excel Programming 7 November 9th 03 10:18 PM


All times are GMT +1. The time now is 03:16 PM.

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"