【发布时间】:2021-06-16 15:48:10
【问题描述】:
有几个常数 TAX1, TAX2, TAX3,...,TAX_y 数据、价格、...的进一步数组 (arrSorted) 我需要将值 arrSorted(allRow, 8) 与 TAX 进行比较并进行一些总和。 但是固定TAX的尾数如何递增?
for i = LBound... to UBound...
for y = 1 to 5
if arrSorted(i,8) = TAX & y then 'i dont know how TAX & y...
' SUMS HERE
end if
next y
next i
我现在有这个循环代码(这不是很好):
Function prepareData(arrSorted() As Variant)
Dim qi As Integer
Dim qy As Integer
Dim sumPrice(0 To 4, 0 To 5) As Variant
For qi = LBound(arrSorted(), 1) To UBound(arrSorted(), 1)
Select Case arrSorted(qi, 8)
Case Is = TAX1
For qy = LBound(sumPrice, 2) To UBound(sumPrice, 2)
sumPrice(0, qy) = sumPrice(0, qy) + arrSorted(qi, qy + 4)
Next qy
Case Is = TAX2
For qy = LBound(sumPrice, 2) To UBound(sumPrice, 2)
sumPrice(1, qy) = sumPrice(1, qy) + arrSorted(qi, qy + 4)
Next qy
Case Is = TAX3
For qy = LBound(sumPrice, 2) To UBound(sumPrice, 2)
sumPrice(2, qy) = sumPrice(2, qy) + arrSorted(qi, qy + 4)
Next qy
Case Is = TAX4
For qy = LBound(sumPrice, 2) To UBound(sumPrice, 2)
sumPrice(3, qy) = sumPrice(3, qy) + arrSorted(qi, qy + 4)
Next qy
Case Is = TAX5
For qy = LBound(sumPrice, 2) To UBound(sumPrice, 2)
sumPrice(4, qy) = sumPrice(4, qy) + arrSorted(qi, qy + 4)
Next qy
Case Else
MsgBox "Alert!", vbCritical
End Select
Next qi
End Function
【问题讨论】:
-
您能否分享使用这些常量的位置以及您尝试填充
arrSorted的位置的完整代码?