View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tatiana Lysenka Tatiana Lysenka is offline
external usenet poster
 
Posts: 1
Default Count totals for the same accounts

On 12 авг, 14:19, arjen van... 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