How to call the Subtotal function by VBA in excel Friday, April 9, 2010

How to call the Subtotal function by VBA in excel

If a formula on the active sheet, then perhaps like this:
Code:

    With Worksheets("统计")
        Range("A3").Formula = _
        "=Subtotal(109, " & .Range("A4", .Cells(LastRow, "A")).Address(, , , True) & ")"
    End WithIf a result, then
Code:
    With Worksheets("统计")
        Range("A3").Value = _
        Application.WorksheetFunction.Subtotal(109, .Range("A4", .Cells(LastRow, "A")))
    End With