View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike Fogleman Mike Fogleman is offline
external usenet poster
 
Posts: 1,092
Default insert formula in last cell

Angela, This should do it for you:

Sub subtotal()
Dim end_data As Long
end_data = ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row
Range("C" & end_data + 1).Formula = "=SUBTOTAL(9,C2:C" & end_data & ")"
End Sub

Mike F
"J_Gold" wrote in message
...
Hi - I would like to be able to subtotal a column of numbers using the
following formula:

=subtotal(9, C2:?) where ? is the last cell that contains data. I would
like to insert the formula in the cell below the last row of data.

The data to be summed are in reports that I download daily and where the
number of rows that contain data will vary. I've tried to figure out how
to do this with a macro, but I'm stumped. Any help is appreciated.

Cheers,

Angela