0

I have this VBA code:

Sub OpenCopyPaste()

Dim wb As Workbook
Dim Reportwb As Workbook

' set report workbook to workbook object (works only is the file is already open)
Set Reportwb = Workbooks("report.xlsx")

' open the source workbook and select the source sheet
Set wb = Workbooks.Open(Filename:="C:\Users\Adryan Permana\Downloads\Test\part8.xlsx")

' copy the source range and paste in 1 line , paste at "C3:E9"
wb.Sheets("Sheet1").Range("C3:E9").Copy
Reportwb.Sheets("Sheet1").Range("C3:E9").PasteSpecial xlPasteValues
Reportwb.Save

End Sub

I want to copy data from "part8.xlsx" without open that file. How can I do that? Many thanks for the help.

Adryan Permana
  • 127
  • 1
  • 1
  • 10
  • You have something here : http://stackoverflow.com/questions/29310458/how-to-copy-data-from-closed-workbookskeeping-them-closed-into-master-workbook – Harsha W Apr 19 '17 at 08:39

1 Answers1

-1
Sub OpenCopyPaste()
Dim wb As Workbook
Dim Reportwb As Workbook
' set report workbook to workbook object (works only is the file is already 
'open)
Set Reportwb = ThisWorkbook
Application.ScreenUpdating = False
' open the source workbook and select the source sheet
Set wb = Workbooks.Open(Filename:="C:\Users\Adryan Permana\Downloads\Test\part8.xlsx")
' copy the source range and paste in 1 line , paste at "C3:E9"
wb.Sheets("Sheet1").Range("C3:E9").Copy
Reportwb.Sheets("Sheet1").Range("C3:E9").PasteSpecial xlPasteValues
wb.Close False
Reportwb.Save
Application.ScreenUpdating = True
End Sub

Try This

MaddyN
  • 1
  • 1