我有下面的代码,但是当我运行宏时,它似乎忽略了我排除“输入”表的事实。有什么想法吗?我知道前面的代码中可能还有其他错误,但我想先修复这个!
Sub export_all()
Dim Path As String
Dim Name As String
Dim ws As Worksheet
Path = Workbooks("CGL Configurator V3.xlsm").Sheets("Input").Range("$C$12")
Name = ActiveSheet.Range("A151")
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Input" Then
Range("A1:AZ151").Copy
Workbooks.Add
Range("A1").PasteSpecial Paste:=xlPasteValues
ActiveWorkbook.SaveAs Filename:=Path & "\" & Name & ".csv", FileFormat:=xlCSVUTF8
Range("A151").Delete
ActiveWorkbook.Save
ActiveWorkbook.Close
End If
Next ws
Workbooks("CGL Configurator V3.xlsm").Sheets("Input").Activate
End Sub
答案1
事实证明,我在 Range("A1:AZ151").Copy 之前缺少一个 '.ws',因此缺少输入表,但由于它是活动表,因此无论如何都会从中复制单元格。