-
[VBA]Sub SubTotal_Accounts()
Dim acctRng As Range, cell As Range
Dim i As Long, ct151 As Long, ct130 As Long
Dim st151 As Long, st130 As Long
ActiveWorkbook.Sheets(1).Activate
Range("A1").Activate
Set acctRng = ActiveSheet.Range("O:O")
For Each cell In acctRng
If cell.Row <> 1 Then
Select Case cell.Value
Case 151:
st151 = st151 + cell.Offset(0, -1).Value
ct151 = ct151 + 1
Case 130:
st130 = st130 + cell.Offset(0, -1).Value
ct130 = ct130 + 1
End Select
End If
Next cell
ActiveWorkbook.Sheets(1).Range("A50").Value = st151
ActiveWorkbook.Sheets(1).Range("B50").Value = ct151
ActiveWorkbook.Sheets(1).Range("A51").Value = st130
ActiveWorkbook.Sheets(1).Range("B51").Value = ct130
End Sub[/VBA]
I kind of scrapped your structure a little bit, if you need help getting this into the program you already have i can do that but this works for me (in the sample data set the subtotals are:
151 ($14143.12 total, 17 count)
130 ($126.62 total, 14 count)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules