Frazzlerock
New Member
- Joined
- May 9, 2018
- Messages
- 2
Morning all,
Quite a novice, but I have inherited a migration tool inwhich it runs a macro and copies all data from various excel spreadsheets andplaces it onto one master copy
during the process I receive a "run time error 1004method of rows of object global failed"
the coding looks like this (ive removed the file url andreplaced with x's)
********************************************************************************************
*********************************************************************************************************
the line highlighted in yellow seems to be the issue
can anyone assist me as to what the problem is? what theerror message means? how to fix it?
it seems to be when it gets to a particular spreadsheet thatthe error occurs
Many Thanks
Quite a novice, but I have inherited a migration tool inwhich it runs a macro and copies all data from various excel spreadsheets andplaces it onto one master copy
during the process I receive a "run time error 1004method of rows of object global failed"
the coding looks like this (ive removed the file url andreplaced with x's)
********************************************************************************************
Code:
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public FSO As Object[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public FromPath As String[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public ToPath As String[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public FileExt As String[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public FNames As String[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public ImportDate As String[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public SourceLastRow1 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public SourceLastRow2 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public SourceLastRow3 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public SourceLastRow4 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public SourceLastRow5 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public SourceLastRow6 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public SourceLastRow7 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public SourceLastRow8 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public SourceLastRow9 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public TargetLastRow1 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public TargetLastRow2 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public TargetLastRow3 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public TargetLastRow4 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public TargetLastRow5 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public TargetLastRow6 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public TargetLastRow7 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public TargetLastRow8 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public TargetLastRow9 As Long[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public TargetWB As Workbook[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public SourceWB As Workbook[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public Filename As String[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]'Public LookupDate As Date[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Private ArchivePath As String[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public WeeklyExportDate As String[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Public MonthlyExportDate As Date[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Sub DataCollection()[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]'Application.ScreenUpdating = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Application.DisplayAlerts = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Application.Calculation = xlCalculationManual[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]'***** (1) SET MIGRATED DATA ARCHIVE PATH[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]ArchivePath ="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" &VBA.Strings.Format(ImportDate, "yyyy-mm-dd") & "\"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Set TargetWB = ThisWorkbook[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]'***** (2) IMPORT & COLLATE DATA[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Filename = Dir(ArchivePath & "*.xlsm")[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] Do WhileLen(Filename) > 0 'IF NEXT FILEEXISTS THEN[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] Set SourceWB =Workbooks.Open(ArchivePath & Filename)[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("1").Unprotect "CCUED"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("3").Unprotect"CCUED"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("4").Unprotect "CCUED"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("5").Unprotect "CCUED"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("6").Unprotect "CCUED"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("7").Unprotect "CCUED"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("8").Unprotect "CCUED"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("9").Unprotect "CCUED"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]TargetLastRow1 =TargetWB.Sheets("1").Range("A" & Rows.Count).End(xlUp).Row+ 1[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetLastRow3= TargetWB.Sheets("3").Range("A" & Rows.Count).End(xlUp).Row+ 1[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetLastRow4= TargetWB.Sheets("4").Range("A" &Rows.Count).End(xlUp).Row + 1[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetLastRow5= TargetWB.Sheets("5").Range("A" &Rows.Count).End(xlUp).Row + 1[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetLastRow6= TargetWB.Sheets("6").Range("A" & Rows.Count).End(xlUp).Row+ 1[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetLastRow7= TargetWB.Sheets("7").Range("A" &Rows.Count).End(xlUp).Row + 1[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetLastRow8= TargetWB.Sheets("8").Range("A" &Rows.Count).End(xlUp).Row + 1[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetLastRow9= TargetWB.Sheets("9").Range("A" &Rows.Count).End(xlUp).Row + 1[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] 'SET SOURCELAST ROW[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] On ErrorResume Next[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("1").ShowAllData[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("1").AutoFilterMode = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] WithSourceWB.Sheets("1").Cells[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] .EntireColumn.Hidden = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] .EntireRow.Hidden = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] End With[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceLastRow1= SourceWB.Sheets("1").Range("A" &Rows.Count).End(xlUp).Row[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("3").ShowAllData[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("3").AutoFilterMode= False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] WithSourceWB.Sheets("3").Cells[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] .EntireColumn.Hidden = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] .EntireRow.Hidden = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] End With[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceLastRow3= SourceWB.Sheets("3").Range("A" & Rows.Count).End(xlUp).Row[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("4").ShowAllData[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("4").AutoFilterMode = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] WithSourceWB.Sheets("4").Cells[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] .EntireColumn.Hidden = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] .EntireRow.Hidden = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] End With[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceLastRow4 =SourceWB.Sheets("4").Range("A" &Rows.Count).End(xlUp).Row[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("5").ShowAllData[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("5").AutoFilterMode = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] WithSourceWB.Sheets("5").Cells[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] .EntireColumn.Hidden = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] .EntireRow.Hidden = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] End With[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceLastRow5= SourceWB.Sheets("5").Range("A" &Rows.Count).End(xlUp).Row[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("6").ShowAllData[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("6").AutoFilterMode= False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] WithSourceWB.Sheets("6").Cells[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] .EntireColumn.Hidden = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] .EntireRow.Hidden = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] End With[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceLastRow6= SourceWB.Sheets("6").Range("A" &Rows.Count).End(xlUp).Row[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("7").ShowAllData[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("7").AutoFilterMode = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] WithSourceWB.Sheets("7").Cells[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] .EntireColumn.Hidden = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] .EntireRow.Hidden = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] End With[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceLastRow7= SourceWB.Sheets("7").Range("A" &Rows.Count).End(xlUp).Row[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("8").ShowAllData[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("8").AutoFilterMode = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] WithSourceWB.Sheets("8").Cells[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] .EntireColumn.Hidden = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] .EntireRow.Hidden = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] End With[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceLastRow8= SourceWB.Sheets("8").Range("A" &Rows.Count).End(xlUp).Row[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("9").ShowAllData[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("9").AutoFilterMode = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] WithSourceWB.Sheets("9").Cells[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] .EntireColumn.Hidden = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] .EntireRow.Hidden = False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] End With[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceLastRow9= SourceWB.Sheets("9").Range("A" & Rows.Count).End(xlUp).Row[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] 'COPY DATA TOTARGET[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("1").Range("A2:CO" &SourceLastRow1 + 1).AutoFilter Field:=11, Criteria1:="<>"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("1").Range("A3:CO" &SourceLastRow1).Cells.SpecialCells(xlCellTypeVisible).Copy[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetWB.Sheets("1").Range("A" &TargetLastRow1).PasteSpecial xlPasteValues[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("3").Range("A1:R" &SourceLastRow3 + 1).AutoFilter Field:=2, Criteria1:="<>"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("3").Range("A2:R" &SourceLastRow3).Cells.SpecialCells(xlCellTypeVisible).Copy[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetWB.Sheets("3").Range("A" &TargetLastRow3).PasteSpecial xlPasteValues[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("4").Range("A1:N" &SourceLastRow4 + 1).AutoFilter Field:=8, Criteria1:="<>"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("4").Range("A2:N"& SourceLastRow4).Cells.SpecialCells(xlCellTypeVisible).Copy[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetWB.Sheets("4").Range("A" &TargetLastRow4).PasteSpecial xlPasteValues[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("5").Range("A1:N" &SourceLastRow5 + 1).AutoFilter Field:=6, Criteria1:="<>"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("5").Range("A2:N" &SourceLastRow5).Cells.SpecialCells(xlCellTypeVisible).Copy[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetWB.Sheets("5").Range("A" &TargetLastRow5).PasteSpecial xlPasteValues[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("6").Range("A2:M" &SourceLastRow6 + 1).AutoFilter Field:=7, Criteria1:="<>"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("6").Range("A3:M" &SourceLastRow6).Cells.SpecialCells(xlCellTypeVisible).Copy[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetWB.Sheets("6").Range("A" & TargetLastRow6).PasteSpecialxlPasteValues[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("7").Range("A1:E" &SourceLastRow7 + 1).AutoFilter Field:=6, Criteria1:="<>"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("7").Range("A2:E" &SourceLastRow7).Cells.SpecialCells(xlCellTypeVisible).Copy[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetWB.Sheets("7").Range("A"& TargetLastRow7).PasteSpecial xlPasteValues[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("8").Range("A2:AH" &SourceLastRow8 + 1).AutoFilter Field:=6, Criteria1:="<>"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("8").Range("A3:AH" &SourceLastRow8).Cells.SpecialCells(xlCellTypeVisible).Copy[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetWB.Sheets("8").Range("A" &TargetLastRow8).PasteSpecial xlPasteValues[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("9").Range("A2:D" &SourceLastRow9 + 1).AutoFilter Field:=6, Criteria1:="<>"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.Sheets("9").Range("A3:D" &SourceLastRow9).Cells.SpecialCells(xlCellTypeVisible).Copy[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetWB.Sheets("9").Range("A" &TargetLastRow9).PasteSpecial xlPasteValues[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] On Error GoTo0[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] SourceWB.CloseFalse[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] Filename = Dir[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] Loop[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetLastRow1 =TargetWB.Sheets("1").Range("A" &Rows.Count).End(xlUp).Row + 1[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetWB.Sheets("1").Range("A1").Copy[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetWB.Sheets("1").Range("I3:I" &TargetLastRow1 - 1).PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] Application.CutCopyMode= False[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000] TargetWB.Sheets("1").Range("I3:I" &TargetLastRow1 - 1).NumberFormat = "0000"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Sheets("ControlPanel").Range("B1").Value = "Data last collated: "& VBA.Strings.Format(Now, "DD/MM/YYYY @ HH:MM")[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]'Application.ScreenUpdating = True[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Application.DisplayAlerts = True[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Application.Calculation = xlCalculationAutomatic[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]Sheets("Control Panel").Select[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]MsgBox "All Done!"[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]End Sub[/COLOR][/SIZE][/FONT]
the line highlighted in yellow seems to be the issue
can anyone assist me as to what the problem is? what theerror message means? how to fix it?
it seems to be when it gets to a particular spreadsheet thatthe error occurs
Many Thanks
Last edited by a moderator: