Hello,
I am working with three workbooks with one summarizing the two. Basically this VBA just removes subtotals, clears contents, brings over new data and puts back the subtotals. I am curious if someone could assist in helping me fix the paste error I am getting when I attempt to paste from Arrivals into Arrivals and Departure Reports' Arrivals tab. Any help would be amazing!
Thanks!!
I am working with three workbooks with one summarizing the two. Basically this VBA just removes subtotals, clears contents, brings over new data and puts back the subtotals. I am curious if someone could assist in helping me fix the paste error I am getting when I attempt to paste from Arrivals into Arrivals and Departure Reports' Arrivals tab. Any help would be amazing!
Code:
Sub Arrival_Departure()'
' Arrival_Departure Macro
' Pulls Data from Arrivals & Departures subtotalling by Date then RegionName.
'
' Keyboard Shortcut: Ctrl+Shift+A
'Unsorts and Clears Arrivals
Sheets("Arrivals").Activate
Range("A1:H50000").Select
Selection.ClearOutline
Selection.ClearContents
'Brings over Data From Arrivals CSV
Windows("Arrivals.csv").Activate
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
ActiveWindow.Close
Windows("Arrival and Departure Reports.xlsm").Activate
Range("A1").Select
ActiveSheet.Paste
'Formats and Subtotals Arrivals
Sheets("Arrivals").Activate
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Subtotal GroupBy:=1, Function:=xlCount, TotalList:=Array(6), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Selection.Subtotal GroupBy:=2, Function:=xlCount, TotalList:=Array(6), _
Replace:=False, PageBreaks:=False, SummaryBelowData:=True
'Unsorts and Clears Departures
Sheets("Departures").Activate
Range("A1:H50000").Select
Selection.ClearOutline
Selection.ClearContents
'Brings over Data From Departures CSV
Windows("Departures.csv").Activate
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
ActiveWindow.Close
Windows("Arrival and Departure Reports.xlsm").Activate
Sheets("Departures").Activate
Range("A1").Select
ActiveSheet.Paste
'Formats and Subtotals Departures
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Subtotal GroupBy:=1, Function:=xlCount, TotalList:=Array(6), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Selection.Subtotal GroupBy:=2, Function:=xlCount, TotalList:=Array(6), _
Replace:=False, PageBreaks:=False, SummaryBelowData:=True
End Sub
Thanks!!