I am receiving a message stating excel cannot find a file located in the path noted below. The file is in the folder and I have no idea how to fix this.
This is my first macro, any help would greatly be appreciated.
Sub CodeDateData()
Dim MyFile As String
MyFile = Dir("I:\MAR_Public\LOGISTICS CDA\LCL Data\Reference Lists PERM99\LCL Inventory Reports for Spotfire\")
Dim lastrow As Long, lastcolmn As Long
Do While Len(MyFile) > 0
If MyFile = "ZZ Spotfire Inv File.xlsm" Then
Exit Sub
End If
Workbooks.Open (MyFile)
Sheets("Code Date").Select
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
lastcolumn = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
Range(Cells(2, 1), Cells(lastrow, lastcolumn)).Copy
Application.DisplayAlerts = False
ActiveWorkbook.Close
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("Code Date").Range(Cells(erow, 1), Cells(erow, 4))
MyFile = Dir
Loop
Application.DisplayAlerts = True
End Sub