On 12 авг, 14:19, arjen van... <arjen__...@hatmail.com> wrote:
> The totals for each can be calculated using an array for all the data and
> then looking for each account #:
>
> Sub CountArray()
>
> Â* Â* Dim arrCount As Variant
> Â* Â* Â* Â* With Sheets("Sheet1")
> Â* Â* Â* Â* Â* Â* arrCount = .Range(.Range("A2"), .Range("A2").End(xlDown) _
> Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â*.End(xlToRight)).Value
> Â* Â* Â* Â* End With
>
> Â* Â* Dim ac19216801, ac19216803, ac19216808 As Long
> Â* Â* Dim i As Long
>
> Â* Â* For i = LBound(arrCount, 1) To UBound(arrCount, 1)
> Â* Â* Â* Â* If arrCount(i, 1) = 19216801 Then
> Â* Â* Â* Â* Â* Â* ac19216801 = ac19216801 + arrCount(i, 2)
> Â* Â* Â* Â* ElseIf arrCount(i, 1) = 19216803 Then
> Â* Â* Â* Â* Â* Â* ac19216803 = ac19216803 + arrCount(i, 2)
> Â* Â* Â* Â* ElseIf arrCount(i, 1) = 19216808 Then
> Â* Â* Â* Â* Â* Â* ac19216808 = ac19216808 + arrCount(i, 2)
> Â* Â* Â* Â* End If
>
> Â* Â* Next
>
> Â* Â* With Sheets("Sheet1")
> Â* Â* Â* Â* .Range("B16").Value = ac19216801
> Â* Â* Â* Â* .Range("B17").Value = ac19216803
> Â* Â* Â* Â* .Range("B18").Value = ac19216808
> Â* Â* End With
>
> End Sub
Thanks a lot for answering. No offence but it's not gonna work. I have
thousands rows. To write a code like this I'd spend hours.
Is it possible to to do a loop compare the first account in a row with
next one until the end. Then second one starts. But if it already was
counted, skip it.
Thanks,
|