Consulting

Results 1 to 6 of 6

Thread: Combine countifs & Subtotal

  1. #1

    Combine countifs & Subtotal

    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))

  2. #2
    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"))

  3. #3
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Subtotal of what?
    Semper in excretia sumus; solum profundum variat.

  4. #4
    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.
    Attached Files Attached Files

  5. #5
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    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), "<>")
    Semper in excretia sumus; solum profundum variat.

  6. #6
    Thank you very much Paulked. Works great.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •