View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
RyanH RyanH is offline
external usenet poster
 
Posts: 586
Default Make an Array 2-dimensional in VBA

Your are right. I apologize, I was being lazy. Hopefully this will explain
things better.

Sign is my User Defined Type.

Type Sign
aryPartDes(1 To 37) As Variant
aryPartQty(1 To 37) As Double
End Type

Side Question: Why can't I use this syntax: aryPartDes(1 To 37) As Range?
Excel throws an error.

With Sign
' onsite service techinician, do not mark up
If chkServicePlan Then
.aryPartDes(35) = Array("", "Ad Tech On Site Service
Techinician", "ea.", CDbl(tbxOnSiteServiceTechCost))
.aryPartQty(35) = 1
Else
.aryPartDes(35) = Empty
.aryPartQty(35) = 0
End If

' software, do mark up
.aryPartDes(36) = PartInfo("Software")
.aryPartQty(36) = 1

' freight charges for modules, do not mark up
.aryPartDes(37) = PartInfo("ModuleShipRate")
.aryPartQty(37) = .ModuleCount * Val(tbxQuantity)

' sum items not to be marked up
Total.NoMarkUpItems = 0
For i = 35 To UBound(.aryPartQty)
If .aryPartQty(i) 0 Then
Total.NoMarkUpItems = Total.NoMarkUpItems + .aryPartQty(i) *
..aryPartDes(i)(1, 4)
End If
Next i

End With ' end Sign With
--
Cheers,
Ryan


"Rick Rothstein" wrote:

You show a "dot" in front of .aryPartDesc and .aryPartQty... what object to
those dots reference back to? In other words, exactly what are
..aryPartDes(35) and .aryPartQty(35) that you are assigning and Array to one
of them and a numeric value to the other? Also, what do you think is in
..aryPartQty that you refer to it in this statement...

For i = 35 To UBound(aryPartQty)

without its dot? Perhaps if you showed us all your (relevant) code, what you
are trying to do would make more sense to us (maybe even including a
description would help).

--
Rick (MVP - Excel)


"RyanH" wrote in message
...
I fill an array with 4 celled ranges. The 4th cell in the Range is a price
of a part. I then use a For...Next Loop to sum those prices. I need the
array that I indicated with "" to be two dimensional (or
.aryPartDes(35)(1,4)) because I am getting a "Subscript out of Range" on
the
line indicated "ERROR". I think because the current array is viewed
like
this .aryPartDes(35)(4) thus it can,t find the price. Any ideas?

' NON MARKUP ITEMS

' onsite service techinician, do not mark up
If chkServicePlan Then
.aryPartDes(35) = Array("", "Ad Tech On Site Service Techinician",
"ea.", CDbl(tbxOnSiteServiceTechCost))

.aryPartQty(35) = 1
Else
.aryPartDes(35) = ""
.aryPartQty(35) = 0
End If

' software, do mark up
.aryPartDes(36) = PartInfo("Software")
.aryPartQty(36) = 1

' freight charges for modules, do not mark up
.aryPartDes(37) = PartInfo("ModuleShipRate")
.aryPartQty(37) = .ModuleCount * Val(tbxQuantity)

' sum items not to be marked up
Total.NoMarkUpItems = 0
For i = 35 To UBound(aryPartQty)
If aryPartQty(i) 0 Then
ERROR Total.NoMarkUpItems = Total.NoMarkUpItems + .aryPartQty(i) *
.aryPartDes(i)(1, 4)
End If
Next i
--
Cheers,
Ryan