我是VBA的新手。我在youtube视频上找到了这个代码,将多个工作簿中的数据复制到Master中,这就是我想要做的。但是,我得到一个编译错误:当它到达“* .xlsx”时无效或不合格的引用它不喜欢句点:帮助给我这个:以句点开头的标识符仅在With块内有效。此错误有以下原因和解决方案: 标识符以句点开头。 完成标识符的限定或删除期限。 有什么建议吗?
Sub copyDataFromMultipleWorkbooksIntoMaster()
Dim FolderPath As String, Filepath As String, Filename As String
FolderPath = "G:\control_chart\"
Filepath = FolderPath & “ * .xlsx”
Filename = Dir(Filepath)
Dim lastrow As Long, lastcolumn As Long
Do While Filename <> “”
Workbooks.Open (FolderPath & Filename)
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
lastcolumn = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
ActiveSheet.Paste Destination:=Worksheets(“Sheet1”).Range(Cells(erow, 1), Cells(erow, lastcolumn))
ActiveSheet.Paste Destination:=Worksheets(“Sheet1”).Range(Cells(erow, 1), Cells(erow, 4))
Filename = Dir
Loop
End Sub