View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default In VBA, possible ot subtotal without selecting?

Kind of - From what I have seen in your code

You have told it to sum the 9th column and your range only has 7 columns.

so probably the better explanation is that the macro doesn't think you know
what you are doing <g.

Perhaps you want to add after these lines:
Set rngsort = Range(Cells(4, 1), Cells(Rows.Count, 7).End(xlDown))
Set rngsubtotal = Range(Cells(3, 1), Cells(Rows.Count, 7).End(xlDown))
set rngsort = rngsort.Resize(,9)
set rngsubtolal = rngsubtotal.Resize(,9)

or change the subtotal command to subtotal on a column 7 or lower. You know
your data better than me.

--
Regards,
Tom Ogilvy



"Celt" wrote:


Actually...that didn't work.

At the first instance of :

rngsubtotal.subtotal GroupBy:=7, Function:=xlSum, TotalList:=Array(9),
_
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
ActiveSheet.Outline.ShowLevels RowLevels:=2

I get a [Run time error '1004' : Subtotal Method of Range class
failed].

Is this telling me that the macro can't tell what it is supposed to
subtotal?


--
Celt
------------------------------------------------------------------------
Celt's Profile: http://www.excelforum.com/member.php...o&userid=19413
View this thread: http://www.excelforum.com/showthread...hreadid=551544