Excel Macros

From DataSelf Knowledge Base
Jump to navigation Jump to search

‏‎

Macro for subtotaling

views imported from SQL db.

Sub RefreshReports()

' ' RefreshReports Macro

' Macro recorded 3/5/2007 by DataSelf '

On Error Resume Next

'

   Sheets("DailyAllocItem").Select
   Range("A6").Select
   ActiveWorkbook.RefreshAll
   Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(3, 9), _
       Replace:=True, PageBreaks:=False, SummaryBelowData:=True
   Selection.AutoFormat Format:=xlRangeAutoFormatSimple, Number:=False, Font _
       :=False, Alignment:=False, Border:=True, Pattern:=False, Width:=False

' ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

   Sheets("DailyAllocCust").Select
   Range("A6").Select
   Selection.Subtotal GroupBy:=4, Function:=xlSum, TotalList:=Array(8), _
       Replace:=False, PageBreaks:=False, SummaryBelowData:=True
   Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(3, 8), _
       Replace:=False, PageBreaks:=False, SummaryBelowData:=True
   Selection.AutoFormat Format:=xlRangeAutoFormatSimple, Number:=False, Font _
       :=False, Alignment:=False, Border:=True, Pattern:=False, Width:=False

' ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

   Sheets("ShippingAllCsts").Select
   Range("A6").Select
   Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(16), _
       Replace:=True, PageBreaks:=False, SummaryBelowData:=True
   Selection.AutoFormat Format:=xlRangeAutoFormatSimple, Number:=False, Font _
       :=False, Alignment:=False, Border:=True, Pattern:=False, Width:=False

' ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True


   Sheets("DailyAllocItem").Select
   Range("A6").Select


' ActiveWorkbook.SaveAs Filename:= _ ' ".\DsReports1.xls", _ ' FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ ' ReadOnlyRecommended:=False, CreateBackup:=False


End Sub