我使用此VBA代碼覆蓋了我所有的工作簿,包括數據透視表和公式轉換爲值。將Excel工作表複製到另一個不含公式的Excel工作簿中
Option Explicit
Sub Copia()
Dim ws As Worksheet, pvt As PivotTable, aWs As Worksheet, lst As ListObject
Set aWs = ActiveWorkbook.ActiveSheet
For Each ws In ActiveWorkbook.Worksheets
With ws
For Each pvt In ws.PivotTables
With pvt.TableRange2
.Copy
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
End With
Next pvt
For Each lst In .ListObjects
If Not lst.AutoFilter Is Nothing Then lst.Range.AutoFilter
Next
If .FilterMode Then .ShowAllData
If .AutoFilterMode Then .AutoFilter.ShowAllData
.UsedRange.Value = .UsedRange.Value
.Activate: .Cells(1, 1).Select
End With
Next
aWs.Activate
Application.CutCopyMode = False
End Sub
我該如何適應它才能將活動工作表或特定工作表複製到新工作簿中?
謝謝!
MD
工程就像一個魅力!非常感謝! –
不客氣 – user3598756