Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,570
- Office Version
- 365
- 2016
- Platform
- Windows
I am experimenting with the code below and failing with my results. The line highlighted in red is giving me an "Unable to get the Subtotal property of the Worksheetfunction class" as I try to get a count the number of occurrences of the string "MIN" in column N of my filtered data worksheet. Any thoughts on the correction needed. Are there any other problems with this code?
Rich (BB code):
Sub compDateData(ByRef LDate As Date)
With ws_ops
.AutoFilterMode = False
tarRow = 32
dtf = LDate
For i = 1 To 7
cntDtOps = Application.WorksheetFunction.CountIf(.Columns(2), dtf)
.Range("A:T").AutoFilter Field:=2, Criteria1:="=" & dtf
cntstmin = Application.WorksheetFunction.Subtotal(103, .Columns(14), "MIN")
sumsalt = Application.WorksheetFunction.Subtotal(109, .Columns(14))
cntsdmin = Application.WorksheetFunction.Subtotal(103, .Columns(15), "MIN")
sumssand = Application.WorksheetFunction.Subtotal(109, .Columns(15))
ws_weeks.Cells(tarRow, 14) = Format(dtf, "DDD DD-MMM-YY")
ws_weeks.Cells(tarRow, 15) = cntDtOps
ws_weeks.Cells(tarRow, 16) = sumsalt
ws_weeks.Cells(tarRow, 17) = cntstmin
ws_weeks.Cells(tarRow, 18) = sumsand
ws_weeks.Cells(tarRow, 19) = cntsdmin
tarRow = tarRow + 1
dtf = dtf + 1
Next i
End With
End Sub