View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Subtotal \ Grand Total in VBA

It sounds like you are using the built in subtotal method. Assume column P
contains the values you want to grandtotal.

After your code that builds the subtotal, try putting in lines of code like
this

set rng = Range("P3",cells(rows.count,"P").End(xlup))
Range("P2").formula = "=subtotal(9," & rng.Address & ")"

Adjust to fit your actual locations.

--
Regards,
Tom Ogilvy


"mrdata" wrote:


I need to subtotal a range at each change in "CTR" with VBA code.
I acheived this with a macro recording but I can't figure out the next
part which is this.

I need to get the Grand total that appears at the bottom of the sum
range
To show up at the top of the worksheet in range ("P2").


I tried to make the cell equal xlSUM but that always gives -4175


Thanks
Charles


--
mrdata
------------------------------------------------------------------------
mrdata's Profile: http://www.excelforum.com/member.php...o&userid=17899
View this thread: http://www.excelforum.com/showthread...hreadid=543677