Option Explicit will not stop errors, it helps prevent you making them
Also, look at your code you needlessly switch off screen updating twice. You switch off displaalerts but don't restore it
It looks like your error handling was clicking in if the sheet isn't found. Never use error handling until the code is working
See if this is better. I've tidied the code up
Option Explicit
Public Sub Alex()
Const strFldrPath As String = "C:\Data\Communications Division\Testing Folder\Working Time Master\Working Time Records\"
Dim wb As Workbook
Dim ws As Worksheet
Dim Filecell As Range
'On Error GoTo err_trap '< remove ' to restore error handling
With Application
.ScreenUpdating = False
.DisplayAlerts = False
For Each Filecell In Intersect(ActiveWorkbook.Sheets("Sheet1").UsedRange, ActiveWorkbook.Sheets("Sheet1").[A:A])
If ActiveWorkbook.ReadOnly = True Then 'Why ????
ThisWorkbook.Sheets("Sheet2").Cells(This 'Why?Workbook.Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row + 1, 1).Value = ActiveWorkbook.Name
ActiveWorkbook.Close False
ElseIf Dir(strFldrPath & Filecell.Text) <> vbNullString Then
Set wb = Workbooks.Open(Filename:=strFldrPath & Filecell.Text)
ws.Copy After:=wb.Sheets(wb.Sheets.Count)
For Each ws In ActiveWorkbook.Worksheets
If ws.Name = "20 DEC 10 - 20 MAR 11" Then
.DisplayAlerts = False
ws.Delete
.DisplayAlerts = True
End If
Next ws
End If
ActiveWorkbook.Close True
Next Filecell
err_trap:
.DisplayAlerts = True
.ScreenUpdating = True
End With
On Error GoTo 0
End Sub
Bookmarks