我编写了这段代码,该代码遍历数据验证列表并在新工作簿中复制工作表。我想保存它,但我可以t. The loop doesn
给我一个错误,并在新工作簿中不断复制和粘贴,但它实际上从未在我设置的目录中保存工作簿的副本
Dim ValidationList As Range
Set ValidationList = Range("BF1:BF13")
VCount = ValidationList.Count
For i = 1 To VCount
FolderPath = "C:\Users\A734810\Desktop\Efficiency"
namesheet = Cells(i, 58)
Path = FolderPath & namesheet & "\*.xlsx"
Filename = Dir(Path)
Range("A8") = Cells(ValidationList(i).Row, ValidationList.Column)
ThisWorkbook.Sheets("Professionals comparative").Copy
ActiveWorkbook.SaveCopyAs Filename:=Filename
Next
答案 0 :(得分:5)
Path = FolderPath & namesheet & "\*.xlsx"
如果单元格Cells(i, 58)
有\
,上面的描述是正确的我猜你有一个" \"根据您的帖子,您没有收到任何错误
问题出在这里
ActiveWorkbook.SaveCopyAs Filename:=Filename
文件已保存,但未保存在您认为的位置;)
Filename
只有文件名。您需要将其更改为
ActiveWorkbook.SaveCopyAs Filename:=FolderPath & namesheet & "\" & Filename