Rocky Smolin
rockysmolin at bchacc.com
Fri Oct 28 22:47:40 CDT 2011
I'm not sure what's going on there but I always use the macro recorder in Excel, and crib the code it generates into my VBA. I'd try that. Rocky -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kenneth W Van Huss Sent: Friday, October 28, 2011 6:58 PM To: Access Developers discussion and problem solving Subject: [AccessD] Excel Subtotal from Access/VBA This is eating my lunch. I am trying to calculate a subtotal in an Excel spreadsheet via automation/VBA Code: Select all With ApXL .Range("A2").Select .Selection.Subtotal GroupBy:=4, Function:=xlSum, TotalList:=Array(12), _ Replace:=True, PageBreaks:=False, SummaryBelowData:=True .ActiveSheet.Outline.ShowLevels RowLevels:=2 .Columns("L:L").Style = "Currency" .Rows("1:1").Font.Bold = True End With I keep getting an error on the ".Selection.sub . .." line. The error message is "The command could not be completed by using the range specified. Select a single cell within the range and try the command again." Any help is greatly appreciated. Ken -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com