我收到一条消息,指出excel无法找到位于下面提到的路径中的文件。该文件位于文件夹中,我不知道如何解决此问题。
这是我的第一个宏,任何帮助都会非常感激。
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