Need Help With Worksheet Paste Method Error

rrabideau

New Member
Joined
Nov 7, 2014
Messages
1
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!

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!!
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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