LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default In VBA, possible ot subtotal without selecting?


As always, thanks in advance for any guidance offered!!!

I have a macro that works just fine up until this section. Excel Gur
Tom Ogilivy provided me with some code that allowed me to set "rngsort
and rngsubtotal" once and use them on all of my worksheets (thank
Tom!!). What makes this tricky (at least for me) is that my sort an
subtotal parameters are not the same on each sheet, however the range
are. This is wht I have done so far:

For Each wS In Worksheets
With wS
Set rngsort = Range(Cells(4, 1), Cells(Rows.Count, 7).End(xlDown))
Set rngsubtotal = Range(Cells(3, 1), Cells(Rows.Count, 7).End(xlDown))
End With
If wS.Name = "Contribs" Then
rngsort.sort Key1:=Range("G4"), Order1:=xlAscending, Header:=xlGuess
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
_
DataOption1:=xlSortNormal
rngsubtotal.subtotal GroupBy:=7, Function:=xlSum, TotalList:=Array(9)
_
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
ActiveSheet.Outline.ShowLevels RowLevels:=2
End If
If wS.Name = "Workplace" Then
rngsort.sort Key1:=Range("E4"), Order1:=xlAscending, Header:=xlGuess
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
_
DataOption1:=xlSortNormal
rngsubtotal.subtotal GroupBy:=5, Function:=xlSum, TotalList:=Array(9)
_
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
ActiveSheet.Outline.ShowLevels RowLevels:=2
End If
' I so some sorting and subtotaling on other sheets ......

Next wS

The macro works fine up until my first use of the range rngsubtotal (i
the first If statement).

Do I have to activate the range or worksheet in order to subtotal? O
is it possible to do so without actually selecting anything (I a
trying to get out of the habit of selecting stuff, but still learning)
Maybe my code is worded incorrectly? (also, is there is a mor
efficient way to do what I am trying to do.... I'm all ears).

Thanks All

--
Cel
-----------------------------------------------------------------------
Celt's Profile: http://www.excelforum.com/member.php...fo&userid=1941
View this thread: http://www.excelforum.com/showthread.php?threadid=55154

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subtotal To Include Item Description On Subtotal Line Tickfarmer Excel Discussion (Misc queries) 2 February 23rd 10 07:56 PM
pasting to subtotal lines without replacing hidden -non-subtotal l harleydiva67 Excel Discussion (Misc queries) 1 October 12th 06 06:02 PM
Bolding the subtotal lines automaticlly When using the Subtotal fu 06Speed6 New Users to Excel 2 October 5th 06 03:52 PM
Subtotal of Subtotal displays Grand Total in wrong row Thomas Born Excel Worksheet Functions 5 January 6th 05 01:46 PM
Sort, Subtotal, Label Subtotal, Insert row Teak Excel Programming 2 April 8th 04 04:14 PM


All times are GMT +1. The time now is 09:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"