That should just be a question of something like this:
Spreadsheet1.Range("A6").Formula = "=SUBTOTAL(9,A1:A5)"
End Sub