PDA

View Full Version : [SOLVED:] Combine countifs & Subtotal



av8tordude
04-17-2020, 08:06 PM
how can i combine this two codes?





WorksheetFunction.CountIfs(Range("A7:A" & LRow), "<>0", Range("K7:K" & LRow), ">0")

WorksheetFunction.Subtotal(9, Range("A7:A" & LRow))

av8tordude
04-18-2020, 01:09 AM
I did some google research and I tried this code, but it flags an error on countifs. Please help. thanks


WorksheetFunction.Subtotal(9, CountIfs(Range("A7:A" & LRow), "<>0", Range("K7:K" & LRow), ">0"))

paulked
04-18-2020, 05:11 AM
Subtotal of what?

av8tordude
04-19-2020, 12:27 AM
There are 2 "BA" listed column A. In column K indicate the status of each position. If a date is listed, it indicates the positions is closed. Only one "BA" indicates the position is closed. I would like to count the number of open positions in T12 and the number of closed positions in T13 when I filter the sheet.

paulked
04-19-2020, 04:25 AM
You don't need subtotal for that.



lr = Cells(Rows.Count, 1).End(3).Row
Range("t12") = WorksheetFunction.CountIfs(Range("a7:a" & lr), "BA", Range("k7:k" & lr), "")
Range("t13") = WorksheetFunction.CountIfs(Range("a7:a" & lr), "BA", Range("k7:k" & lr), "<>")

av8tordude
04-19-2020, 04:44 AM
Thank you very much Paulked. Works great.