Hi DAK266
Modify your Code to this
Set Rng = Range("A4:A5")
For Each Row In Rng.Rows
For Each cell In Row.Cells
On Error Resume Next
Dim errors1 As String
errors1 = "C:\asdf\test\" & Format(cell.Value) & ".csv"
If FileFolderExists(errors1) Then
Workbooks.Open errors1, True, True
ThisWorkbook.Sheets(cell.Value).Range("A1:Z50000").Value = ActiveWorkbook.ActiveSheet.Range("A1:Z50000").Value
ActiveWorkbook.Close False
Else
MsgBox errors1 & " does not exist"
End If
Next cell
Next Row
and add this Function
Public Function FileFolderExists(strFullPath As String) As Boolean
'Author : Ken Puls (www.excelguru.ca)
'Macro Purpose: Check if a file or folder exists
On Error GoTo EarlyExit
If Not Dir(strFullPath, vbDirectory) = vbNullString Then FileFolderExists = True
EarlyExit:
On Error GoTo 0
End Function
Bookmarks