Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Excel Subtotals

Good Morning,

I am working with some code that exports from Access to Excel and then
subtotals in Excel. Like the code below:

With xlTop.Range("A:P")
.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=xlSummaryBelow
End With

The problem is that the width of the recordset being subtotaled on can
change (it will not necessarily be 15 columns wide). Is there a way to make
this range dynamic?

Thanks,

Austin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Excel Subtotals

Try thjis

Sub test()

Dim MyArray() As Variant

StartCol = 3
EndCol = 15

ReDim MyArray(0 To (EndCol - StartCol))
For i = StartCol To EndCol
MyArray(i - StartCol) = i
Next i

Set sht = Sheets("Sheet1")

With sht.Range("A:P")
.Subtotal GroupBy:=1, Function:=xlSum, _
TotalList:=MyArray, _
Replace:=True, _
PageBreaks:=False, _
SummaryBelowData:=xlSummaryBelow
End With
End Sub


"Austin" wrote:

Good Morning,

I am working with some code that exports from Access to Excel and then
subtotals in Excel. Like the code below:

With xlTop.Range("A:P")
.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=xlSummaryBelow
End With

The problem is that the width of the recordset being subtotaled on can
change (it will not necessarily be 15 columns wide). Is there a way to make
this range dynamic?

Thanks,

Austin

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Excel Subtotals

Perfect, thanks Joel

"Joel" wrote:

Try thjis

Sub test()

Dim MyArray() As Variant

StartCol = 3
EndCol = 15

ReDim MyArray(0 To (EndCol - StartCol))
For i = StartCol To EndCol
MyArray(i - StartCol) = i
Next i

Set sht = Sheets("Sheet1")

With sht.Range("A:P")
.Subtotal GroupBy:=1, Function:=xlSum, _
TotalList:=MyArray, _
Replace:=True, _
PageBreaks:=False, _
SummaryBelowData:=xlSummaryBelow
End With
End Sub


"Austin" wrote:

Good Morning,

I am working with some code that exports from Access to Excel and then
subtotals in Excel. Like the code below:

With xlTop.Range("A:P")
.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=xlSummaryBelow
End With

The problem is that the width of the recordset being subtotaled on can
change (it will not necessarily be 15 columns wide). Is there a way to make
this range dynamic?

Thanks,

Austin

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
Subtotals problem: Excel 2003 (not, AFAIK, the nested subtotals bug) AndyCotgreave Excel Discussion (Misc queries) 3 October 24th 07 11:32 AM
Original subtotals should not be within nested subtotals in excel Mirage Excel Worksheet Functions 1 June 6th 07 01:37 AM
Subtotals: Nested subtotals below higher subtotal RobN Excel Discussion (Misc queries) 1 July 20th 06 09:04 PM
How do I copy an outline w/ subtotals & paste just the subtotals av Excel Discussion (Misc queries) 1 June 20th 05 11:35 PM
Problem with nested subtotals, placing secondary subtotals BELOW . Dawn Cameron Excel Discussion (Misc queries) 1 June 3rd 05 10:13 PM


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