Dear all,
I hope you are all well.
I am having the following error:
Run-time error '1004'
Select method of Range class failed
This error is on the Workbook.Close event in red:
This code copy information from a "Child" document to a "Master".![]()
Sub Update_Info_Analytics_Reg() Sheets("Registrations").Activate Application.ScreenUpdating = False 'prevents screen flashing through sheets during code Application.StatusBar = "Please wait ... Run Mobile copy in progress" 'WorkBooks Dim iRowReg As Long Dim LR As Long Dim wbMaster As Workbook Dim wbAnalytics As Workbook 'Setting Worksheets Dim wsMasterReg As Worksheet 'Master Value Map Registrations Dim wsAnalyticsReg As Worksheet 'Pilot Analytics 'Setting Worksheets and Workbooks locations Set wbMaster = Workbooks("Pilot_Master_Dashboard.xlsm") 'Master Set wsMasterReg = wbMaster.Sheets("Registrations") 'Master Registrations page Set wbAnalytics = Workbooks.Open(Filename:="C:\Users\PIPO\Documents\Analytics_DashBoard.xlsm") 'Pilot Analytics file Set wsAnalyticsReg = wbAnalytics.Sheets("Nomination") 'Pilot Analytics Registrations Sheet wsMasterReg.Range("D13:I1000").ClearContents 'Finds first empty row in Master's Registrations table iRowReg = wsMasterReg.Range("E" & Rows.Count).End(xlUp).Row + 1 'Copy Registrations from Child (Analytics) to Master 'Value Map wsAnalyticsReg.Range("AH13:AH732").Copy wsMasterReg.Cells(iRowReg, 4).PasteSpecial xlPasteValues 'Customer Name wsAnalyticsReg.Range("D13:D732").Copy wsMasterReg.Cells(iRowReg, 5).PasteSpecial xlPasteValues 'Customer Number wsAnalyticsReg.Range("E13:E732").Copy wsMasterReg.Cells(iRowReg, 6).PasteSpecial xlPasteValues 'Country wsAnalyticsReg.Range("G13:G732").Copy wsMasterReg.Cells(iRowReg, 7).PasteSpecial xlPasteValues 'Region wsAnalyticsReg.Range("H13:H732").Copy wsMasterReg.Cells(iRowReg, 8).PasteSpecial xlPasteValues 'Dedicated ESA wsAnalyticsReg.Range("S13:S732").Copy wsMasterReg.Cells(iRowReg, 9).PasteSpecial xlPasteValues wsMasterReg.Activate Application.CutCopyMode = False wbAnalytics.Close False Set wbAnalytics = Nothing Set wsAnalyticsReg = Nothing Set wsMasterReg = Nothing Application.ScreenUpdating = True Application.StatusBar = "" Call Update_Info_BPI_Reg End Sub
I have a similar Master file with the exact codes (from other files) and it works perfectly closing the "Child" files without any errors.
Any ideas why on this code it gives me the error?
Your assistance will be highly appreciated.
Best regards,
Filipe Oliveira
Bookmarks