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: 144
Default Code for Subtotals

Hi,

I am trying to use the Excel Subtotals function for a scenario where the
number of columns needing to be subtotaled varies -- there may be 4 columns
in one run of the code, but there may be 20 columns in the next run. Below
is the recorded code I have tinkered with -- but I am stuck on how to code it
in a loop so that the number of columns can be set differently each time the
code is run. Any suggestions are appreciated!

'The headers are in row 2 and the actual data to be subtotaled begins in
row 3
With Sheets("Commission by Entity breakdown")
.Range("A2").subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(4, 6,
7, 9, _
11, 13, 15, 17, 19, 20, 22, 24, 26, 28, 29, 31, 33, 34, 35,
37), Replace:=True, PageBreaks:= _
False, SummaryBelowData:=False
End With

--
Robert
 
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
Subtotals problem: Excel 2003 (not, AFAIK, the nested subtotals bug) AndyCotgreave Excel Discussion (Misc queries) 3 October 24th 07 11:32 AM
vba code for subtotals and percentages pcscsr[_9_] Excel Programming 0 November 3rd 04 07:41 PM
vba code for subtotals and percentages pcscsr[_8_] Excel Programming 1 November 3rd 04 03:03 PM
vba code for subtotals and percentages pcscsr[_7_] Excel Programming 1 November 3rd 04 12:32 PM
**HELP** VBA code to insert subtotals farmer[_2_] Excel Programming 1 May 28th 04 08:24 PM


All times are GMT +1. The time now is 03:06 PM.

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"