(Solved) – Copy from 2 workbooks into 1 workbook


Getting an

run time error 1004

when trying to copy from two different workbooks into the same workbook

I am copying certain cells from two worksheets into one worksheet. I have tried different several ways to get other errors so I am back to this one.

Sub Range_Copy_Examples()

Dim wb As Workbook
Dim wb1 As Workbook
Dim wbData As Range
Dim wbData1 As Range
Dim wbExtract As Range
Dim wbExtract1 As Range

    Set wb = ActiveWorkbook
    Set wbData = wb.Worksheets("GAI").Range("A1")
    Set wbExtract = wb.Worksheets("Report").Range("A3:I3")

    wbData.CurrentRegion.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=wbExtract

    Set wb1 = ActiveWorkbook
    Set wbData1 = wb1.Worksheets("FUND").Range("H1")
    Set wbExtract1 = wb.Worksheets("Report").Range("J3:K3")

    wbData1.CurrentRegion.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=wbExtract1

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *