Snailspace
Board Regular
- Joined
- Jan 28, 2009
- Messages
- 56
I’m trying to calculate the totals based on the Account number (Col E) and the aging criteria (Col J), to come up with the total for the account, and a total per account based on the aging. The idea being I can store these in variables to perform further calculations.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
I tried Sumproduct, which I could only get to work if I dropped it in as a formula rather than evaluating in VBA. This seemed to be very slow. The best I’ve been able to come up with is popping it into an array and looping through. I’m sure this is not the most efficient way.
TIA
SP<o></o>
<o></o>
I tried Sumproduct, which I could only get to work if I dropped it in as a formula rather than evaluating in VBA. This seemed to be very slow. The best I’ve been able to come up with is popping it into an array and looping through. I’m sure this is not the most efficient way.
TIA
SP<o></o>
Rich (BB code):
<o:p>Dim x As Variant
Dim r As Long, c As Integer, arrRow As Long
Dim accTotal As Double
Dim d130 As Double
Dim accNo As String
x = Range("A1:M11000").Value</o:p>
<o:p>For r = 2 To UBound(x, 1)
accTotal = 0
d130 = 0
'x(r,c)
accNo = (x(r, 5))
For arrRow = 2 To UBound(x, 1)
'Total
If (x(arrRow, 5)) = accNo Then
accTotal = accTotal + (x(arrRow, 11))
End If
'1-30 days
If (x(arrRow, 5)) = accNo And (x(arrRow, 10)) = "1-30 Days" Then
d130 = d130 + (x(arrRow, 11))
End If
Next arrRow
x(r, 12) = accTotal
x(r, 13) = d130
Next r</o:p>
<o:p>Range("A1:M11000") = x</o:p>