I would like to copy data from an external workbook and save it into my current workbook. There is plenty of code for this. What I have not found is how to do this without the external workbook ever opening. Is this possible and how would you do this?
All I can see related to this is using the ActiveWindow.Visible = false statement below, but the external workbook still opens first prior to this statement executing. I just want to get data from that workbook without either the time involved in loading/displaying the workbook or having macros like the workbook_open() executing.
Thanks
All I can see related to this is using the ActiveWindow.Visible = false statement below, but the external workbook still opens first prior to this statement executing. I just want to get data from that workbook without either the time involved in loading/displaying the workbook or having macros like the workbook_open() executing.
Thanks
Code:
Dim wbExternal As Workbook, wbInternal As Workbook
Dim wsExternal As Worksheet, wsInternal As Worksheet
Dim filePath As String: filePath = "C:\a\readfrom.xlsm"
Dim wkbSource As Workbook
Dim wkbDest As Workbook
Dim sheetToCopy1 As Worksheet
Set wkbDest = thisWorkbook
Set wkbSource = Application.Workbooks.Open(filePath)
ActiveWindow.Visible = False
Set sheetToCopy1 = wkbSource.Sheets(sheetnameObjectives)
sheetToCopy1.Copy after:=wkbDest.Sheets(1)