Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Subtotal Macro Help

I have some VB that SHOULD subtotal each tab that is not equal to "Source
Data" but when I run the Macro it subtotals multiple times on the same tab
instead of moving to the next tab after subtotaling. Can anyone help me
straighten out my For statement? Here's the Macro:

For Each ws In ActiveWorkbook.Sheets
If ws.Name < "Source Data" Then _
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(11, 12,
13 _
, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23), Replace:=True,
PageBreaks:=False, _
SummaryBelowData:=True
Next ws
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Subtotal Macro Help

For Each ws In ActiveWorkbook.Sheets
If ws.Name < "Source Data" Then
ws.Activate
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, _
TotalList:= Array(11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23), _
Replace:=True, _
PageBreaks:=False, _
SummaryBelowData:=True
End If
Next ws

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"masterbaker" wrote in message
...
I have some VB that SHOULD subtotal each tab that is not equal to "Source
Data" but when I run the Macro it subtotals multiple times on the same tab
instead of moving to the next tab after subtotaling. Can anyone help me
straighten out my For statement? Here's the Macro:

For Each ws In ActiveWorkbook.Sheets
If ws.Name < "Source Data" Then _
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(11,
12,
13 _
, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23), Replace:=True,
PageBreaks:=False, _
SummaryBelowData:=True
Next ws



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Subtotal Macro Help

Perfect Bob, Thanks. I just needed to activiate the sheet and end my if
statement.

Easy fix to a stupid error....Thanks!


"Bob Phillips" wrote:

For Each ws In ActiveWorkbook.Sheets
If ws.Name < "Source Data" Then
ws.Activate
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, _
TotalList:= Array(11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23), _
Replace:=True, _
PageBreaks:=False, _
SummaryBelowData:=True
End If
Next ws

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"masterbaker" wrote in message
...
I have some VB that SHOULD subtotal each tab that is not equal to "Source
Data" but when I run the Macro it subtotals multiple times on the same tab
instead of moving to the next tab after subtotaling. Can anyone help me
straighten out my For statement? Here's the Macro:

For Each ws In ActiveWorkbook.Sheets
If ws.Name < "Source Data" Then _
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(11,
12,
13 _
, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23), Replace:=True,
PageBreaks:=False, _
SummaryBelowData:=True
Next ws




Reply
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
sort macro, subtotal and add lines after subtotal David Excel Discussion (Misc queries) 1 August 29th 09 10:56 AM
Macro add row and subtotal simplymidori[_2_] Excel Discussion (Misc queries) 0 April 30th 08 12:34 AM
macro excel subtotal in subtotal GBO Excel Discussion (Misc queries) 2 November 29th 07 02:15 PM
A MACRO ON SUBTOTAL sylink Excel Programming 0 August 11th 05 04:55 PM
Subtotal Macro [email protected] Excel Worksheet Functions 1 January 26th 05 11:13 AM


All times are GMT +1. The time now is 06:59 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"