Multidimensional Array

R

Rpettis31

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
 
J

Joel

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
 
J

Jim Cone

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"
<[email protected]>
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top