extra rows in subtotal

bobvilla

New Member
Joined
Dec 28, 2010
Messages
13
On my spreadsheet, I have a macro that updates a query on the page then performs a subtotal to average the results.
The problem I'm having is that on the last subtotal, it inserts a whole bunch of extra rows between the last row of data and the actual subtotal. On the last one in particular, it inserted over 38,000 blank rows.
What am I doing wrong and how do I fix it?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Here is the macro code. The part in red relates to the sheet with the subtotals

' TM Macro
' Macro recorded 8/13/2010 by
'
'
Sheets("TM1").Select
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("A1").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Columns("D:D").Select
Selection.TextToColumns Destination:=Range("D1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="/", FieldInfo:=Array(1, 5), TrailingMinusNumbers:=True
Columns("E:E").Select
Selection.TextToColumns Destination:=Range("E1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="/", FieldInfo:=Array(1, 5), TrailingMinusNumbers:=True
Columns("D:E").Select
Columns("D:E").EntireColumn.AutoFit
Columns("A:A").Select
Columns("A:A").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Columns( _
"A:A"), CopyToRange:=Range("T1"), Unique:=True
ActiveWindow.SmallScroll ToRight:=9
Range("V2:X2").Select
Selection.AutoFill Destination:=Range("V2:X2500"), Type:=xlFillDefault
Range("V2:X2500").Select
Range("A1").Select
Sheets("TM2").Select
Range("A1").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Columns("A:M").Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Key2:=Range("A2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
Selection.Subtotal GroupBy:=1, Function:=xlAverage, TotalList:=Array(6), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Range("N2:P2").Select
Selection.AutoFill Destination:=Range("N2:P15000"), Type:=xlFillDefault
Range("N2:P15000").Select
Sheets("TM MINPAY").Select
Range("A8:F8").Select
Selection.AutoFill Destination:=Range("A8:F2500"), Type:=xlFillDefault
Range("A8:F2500").Select
Range("H8").Select
Selection.AutoFill Destination:=Range("H8:H2500"), Type:=xlFillDefault
Range("H8:H2500").Select
Range("A1").Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,278
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top