LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Thief_
 
Posts: n/a
Default Automate Subtotals Insertion?

I'm trying to automate a Subtotal function, ie, I want to SUM the data
in columns C onwards for each change in column A:

Code:
Private Sub SubTotalSummaryData(LasDateCol As Byte)
Dim DataArray() As Byte, cnt As Byte, i As Byte

With Worksheets("Summary")
' Populate array of all used columns of data- used by the
Subtotal function.
ReDim DataArray(LasDateCol - 2)
cnt = 0
For i = 3 To LasDateCol
DataArray(cnt) = i
cnt = cnt + 1
Next i
.UsedRange.Subtotal GroupBy:=1, Function:=xlSum,
TotalList:=Array(DataArray()), Replace:=True, PageBreaks:=False,
SummaryBelowData _
:=True
End With
End Sub




The number of columns present will vary each time the procedure is
called thus I tried creating an array of all the used columns via the
FOR....NEXT loop, but VBA doesn't like it.

Any ideas?


--
|
+-- Julian
|


 
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
Excel gets subtotals out of order using multiple sorts and subtot. jeffl Excel Discussion (Misc queries) 1 March 29th 05 01:35 AM
Subtotals Joan Excel Discussion (Misc queries) 1 March 2nd 05 10:33 PM
Subtotals Problem when Filtering Brenda Rueter Excel Discussion (Misc queries) 2 February 15th 05 09:05 PM
In Excel, how do you copy and paste just the subtotals into anoth. mmiazga Excel Discussion (Misc queries) 4 February 13th 05 01:17 AM
why are nested subtotals coming out below outer subtotals? Hendy Excel Worksheet Functions 2 January 18th 05 08:09 PM


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