Broken macro in Excel 2003: part II

G

Guest

I posted on this once before and got some advice that I've followed up on
(thanks!) I sp1 installed and tried the registry edit mentioned in article
831824, but no luck there so I've set it back to its original setting. I
think I've come up with some of the offending code that ran well in Excel
2000 but breaks in Excel 2003. As of the first line of this code, all of the
applicable data is selected, but by the time it gets to the end there are
many rows that fall below the bottom of the selection.

' Subtotal by company name
Range("A5", Range("A5").End(xlDown).End(xlToRight)).Select
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(5), _
Replace:=False, PageBreaks:=False, SummaryBelowData:=True
Range("A5", Range("A5").End(xlToRight).End(xlDown)).Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(5), _
Replace:=False, PageBreaks:=False, SummaryBelowData:=True

Any ideas that you can provide will be greatly appreciated.
 
G

Guest

Success! Apparently when the macro would run in Excel 2000, there was a
blank line in between the last subtotal and the grand total. So, the
original programmer (whoever that was) added the second line here to deal
with that (which I fixed by commenting out. Net effect on Excel 2003 was
that the last subtotal disappeared causing a corrupt report.

Rows(SheetLastRow - 1).Select
'Selection.Delete Shift:=xlUp
Columns("A:A").EntireColumn.AutoFit
Columns("B:B").EntireColumn.AutoFit
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Subtotal Formatting 2
Subtotal by VBA 5
Subtotal macro in each worksheet 13
Subtotals 2
subtotal question 1
Subtotal Macro Help 2
Subtotal function 2
Toggle Subtotal on and off 2

Top