ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multidimensional Array (https://www.excelbanter.com/excel-programming/424736-multidimensional-array.html)

Rpettis31

Multidimensional Array
 
I am trying to set my code with an array to obtain values. For example
pieces per month by factory. I was hoping to store the factory name as the
parent and the child array as the totals per month. Currently I have this as
a static array.
' Prepaid Inventory
Dim PrePaid(1 To 12) As Currency
Dim PrePaid1(1 To 12) As Currency
Dim PrePaid2(1 To 12) As Currency
Dim PrePaid3(1 To 12) As Currency

Dim ArrFactory(1 To 4) As String
ArrFactory(1) = "Panan Jiayuan Househ"
ArrFactory(2) = "Xianju Fenda - New"
ArrFactory(3) = "Curug"
ArrFactory(4) = "PT Astari"


Dim arrCount As Integer
Dim n As Integer
Dim g As Integer
n = 43 'Plan Prod
g = 38 'Reciepts by month

For Accum = 1 To 12

For arrCount = 2 To 2000

Select Case Cells(arrCount, 6)

Case ArrFactory(1, 0)

PrePaid(Accum) = PrePaid(Accum) + (Cells(arrCount, g) *
Cells(arrCount, 13))
If g 42 Then _
PrePaid(Accum) = PrePaid(Accum) + (Cells(arrCount, n) *
Cells(arrCount, 13))

Case ArrFactory(1)
PrePaid1(Accum) = PrePaid1(Accum) + (Cells(arrCount, g) *
Cells(arrCount, 13))
If g 42 Then _
PrePaid1(Accum) = PrePaid1(Accum) + (Cells(arrCount, n) *
Cells(arrCount, 13))

End Select
Next arrCount
n = n + 6
g = g + 6

Next Accum

joel

Multidimensional Array
 
From
Dim PrePaid(1 To 12) As Currency
Dim PrePaid1(1 To 12) As Currency
Dim PrePaid2(1 To 12) As Currency
Dim PrePaid3(1 To 12) As Currency

to
Dim PrePaid(1 To 12, 4) As Currency
Dim PrePaid1(1 To 12, 4) As Currency
Dim PrePaid2(1 To 12, 4) As Currency
Dim PrePaid3(1 To 12, 4) As Currency


Or

from
Dim ArrFactory(1 To 4) As String

to
Dim ArrFactory(1 To 4, 12) As String




"Rpettis31" wrote:

I am trying to set my code with an array to obtain values. For example
pieces per month by factory. I was hoping to store the factory name as the
parent and the child array as the totals per month. Currently I have this as
a static array.
' Prepaid Inventory
Dim PrePaid(1 To 12) As Currency
Dim PrePaid1(1 To 12) As Currency
Dim PrePaid2(1 To 12) As Currency
Dim PrePaid3(1 To 12) As Currency

Dim ArrFactory(1 To 4) As String
ArrFactory(1) = "Panan Jiayuan Househ"
ArrFactory(2) = "Xianju Fenda - New"
ArrFactory(3) = "Curug"
ArrFactory(4) = "PT Astari"


Dim arrCount As Integer
Dim n As Integer
Dim g As Integer
n = 43 'Plan Prod
g = 38 'Reciepts by month

For Accum = 1 To 12

For arrCount = 2 To 2000

Select Case Cells(arrCount, 6)

Case ArrFactory(1, 0)

PrePaid(Accum) = PrePaid(Accum) + (Cells(arrCount, g) *
Cells(arrCount, 13))
If g 42 Then _
PrePaid(Accum) = PrePaid(Accum) + (Cells(arrCount, n) *
Cells(arrCount, 13))

Case ArrFactory(1)
PrePaid1(Accum) = PrePaid1(Accum) + (Cells(arrCount, g) *
Cells(arrCount, 13))
If g 42 Then _
PrePaid1(Accum) = PrePaid1(Accum) + (Cells(arrCount, n) *
Cells(arrCount, 13))

End Select
Next arrCount
n = n + 6
g = g + 6

Next Accum


Jim Cone[_2_]

Multidimensional Array
 
What is a "parent" array?
What is a "child" array?
What version of XL are you using?
And what is your question?
--
Jim Cone
Portland, Oregon USA



"Rpettis31"

wrote in message
I am trying to set my code with an array to obtain values. For example
pieces per month by factory. I was hoping to store the factory name as the
parent and the child array as the totals per month. Currently I have this as
a static array.
' Prepaid Inventory
Dim PrePaid(1 To 12) As Currency
Dim PrePaid1(1 To 12) As Currency
Dim PrePaid2(1 To 12) As Currency
Dim PrePaid3(1 To 12) As Currency

Dim ArrFactory(1 To 4) As String
ArrFactory(1) = "Panan Jiayuan Househ"
ArrFactory(2) = "Xianju Fenda - New"
ArrFactory(3) = "Curug"
ArrFactory(4) = "PT Astari"


Dim arrCount As Integer
Dim n As Integer
Dim g As Integer
n = 43 'Plan Prod
g = 38 'Reciepts by month

For Accum = 1 To 12
For arrCount = 2 To 2000
Select Case Cells(arrCount, 6)
Case ArrFactory(1, 0)
PrePaid(Accum) = PrePaid(Accum) + (Cells(arrCount, g) *
Cells(arrCount, 13))
If g 42 Then _
PrePaid(Accum) = PrePaid(Accum) + (Cells(arrCount, n) *
Cells(arrCount, 13))

Case ArrFactory(1)
PrePaid1(Accum) = PrePaid1(Accum) + (Cells(arrCount, g) *
Cells(arrCount, 13))
If g 42 Then _
PrePaid1(Accum) = PrePaid1(Accum) + (Cells(arrCount, n) *
Cells(arrCount, 13))
End Select
Next arrCount
n = n + 6
g = g + 6
Next Accum


All times are GMT +1. The time now is 08:47 AM.

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