Hello,
I found this code below and modified it to work for my purpose. It goes into a workbook and copies a range into another workbook in a specific sheet.
I keep getting an error on the "Set wb1 = Workbooks" line. It appears it can't find the WB. Can someone tell me what I'm missing?
I found this code below and modified it to work for my purpose. It goes into a workbook and copies a range into another workbook in a specific sheet.
I keep getting an error on the "Set wb1 = Workbooks" line. It appears it can't find the WB. Can someone tell me what I'm missing?
Code:
Sub CopyFromClosedCombinedInventoryWB()
'This macro copies the combined data fropm a closed WB which holds the inventory data.
' Defines variables
Dim wb1 As Workbook, wb2 As Workbook
Dim dteProcess As String
dteProcess = Format(Date, "dd-mmm-yyyy") & ".xls"
' Disable screen updating to reduce screen flicker
Application.ScreenUpdating = False
' Define which workbook is which
Set wb1 = Workbooks("Securitas Rental Report " & dteProcess) '*****HERE IS WHERE THE ERROR OCCURS************
Set wb2 = Workbooks.Open("\\fleet.ad\data\Data1\VMSSHARE\FS\FPSCOEASSO\Temporary Fleet Reports\Securitas Rental Report\Inventory Report Depository\Combined Inventory Report.xlsx")
' Copy range A1:W70 from the Data sheet of wb2
wb2.Sheets("Combined").Range("A1:D65000").Copy
' Paste the copied data to range A1 of the Data sheet in wb1
wb1.Sheets("Temp Inventory").Range("A1").Paste
' Close wb2
wb2.Close
' Re-enable screen updating
Application.ScreenUpdating = True
End Sub