Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

https://stackoverflow.com/questions/16565270/copying-external-excel-sheet-to-current-workbook-using-vba

Public Sub OpenWBandCopy()
Dim wbk1 As Workbook, wbk2 As Workbook

fileStr = Environ("USERPROFILE") & "\Downloads\WB.xlsx"

    Set wbk1 = ActiveWorkbook
    Set wbk2 = Workbooks.Add(fileStr)

    'wbk2.Sheets("Sheet Name").Copy After:=Workbooks("WorkbookNameYouCopyCodeInto").Sheets(1)
    'wbk2.Sheets("Sheet Name").Copy After:=wbk1.Sheets(1)
    wbk2.Worksheets(1).Copy After:=wbk1.Sheets(1)
    wbk2.Close SaveChanges:=False
End Sub
  • No labels