Using VBA to Copy Paste onto another Workbook

ameenuksg

Board Regular
Joined
Jul 11, 2017
Messages
83
Hi I am trying to copy paste filtered data using VBA onto another workbook under 4 separate sheets but it doesnt seem to work

Code:
Sub Macro1()
'
' Macro1 Macro
'

'
    ActiveCell.Offset(2703, 1).Range("A1").Select
    ActiveSheet.ListObjects("Table132415").Range.AutoFilter Field:=3, Criteria1 _
        :="=Inside Port Direct", Operator:=xlOr, Criteria2:= _
        "=Inside Port Indirect"
    ActiveSheet.ListObjects("Table132415").Range.AutoFilter Field:=8, Criteria1 _
        :="MDT CPH"
    ActiveCell.Offset(-2703, -2).Range("A1:AQ2801").Select
    ActiveCell.Offset(-2703, -1).Range("A1").Activate
    Selection.Copy
    Windows("Domestic MMM YYYY Invoice Summary Week.xlsm").Activate
    ActiveSheet.Paste
    ActiveSheet.Next.Select
    Windows( _
        "Copy of SGL TO MDT Jun 2018 DOMESTIC SIN KPI STATISTICS 20 Jun 2018 week 24.xlsm" _
        ).Activate
    ActiveWindow.SmallScroll Down:=-15
    ActiveCell.Offset(2703, 6).Range("A1").Select
    ActiveSheet.ListObjects("Table132415").Range.AutoFilter Field:=8, Criteria1 _
        :="MDT FRH"
    ActiveCell.Offset(-2703, -7).Range("A1:AQ2801").Select
    ActiveCell.Offset(-2703, -6).Range("A1").Activate
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Domestic MMM YYYY Invoice Summary Week.xlsm").Activate
    ActiveSheet.Paste
    Windows( _
        "Copy of SGL TO MDT Jun 2018 DOMESTIC SIN KPI STATISTICS 20 Jun 2018 week 24.xlsm" _
        ).Activate
    Application.CutCopyMode = False
    ActiveCell.Offset(2706, 6).Range("A1").Select
    ActiveSheet.ListObjects("Table132415").Range.AutoFilter Field:=8
    ActiveSheet.ListObjects("Table132415").Range.AutoFilter Field:=3, Criteria1 _
        :="Outside port"
    ActiveSheet.ListObjects("Table132415").Range.AutoFilter Field:=8, Criteria1 _
        :="MDT CPH"
    ActiveCell.Offset(-2706, -7).Range("A1:AQ2801").Select
    ActiveCell.Offset(-2706, -6).Range("A1").Activate
    Selection.Copy
    Windows("Domestic MMM YYYY Invoice Summary Week.xlsm").Activate
    ActiveSheet.Next.Select
    ActiveSheet.Paste
    ActiveSheet.Next.Select
    Windows( _
        "Copy of SGL TO MDT Jun 2018 DOMESTIC SIN KPI STATISTICS 20 Jun 2018 week 24.xlsm" _
        ).Activate
    ActiveWindow.SmallScroll Down:=-48
    ActiveCell.Offset(2709, 6).Range("A1").Select
    ActiveSheet.ListObjects("Table132415").Range.AutoFilter Field:=8, Criteria1 _
        :="MDT FRH"
    ActiveCell.Offset(-2709, -7).Range("A1:AQ2801").Select
    ActiveCell.Offset(-2709, -6).Range("A1").Activate
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Domestic MMM YYYY Invoice Summary Week.xlsm").Activate
    ActiveSheet.Paste
    Sheets("InsidePort CPH w").Select
    Windows( _
        "Copy of SGL TO MDT Jun 2018 DOMESTIC SIN KPI STATISTICS 20 Jun 2018 week 24.xlsm" _
        ).Activate
    Application.CutCopyMode = False
End Sub


Any help would be grateful
 
Last edited by a moderator:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,223,896
Messages
6,175,263
Members
452,627
Latest member
KitkatToby

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