感谢您在这里所做的所有努力,我已经逆向工程并开发了一个代码,但我在一件小事上遇到了困难。从 WS2 复制时我想要做的是粘贴,因为我不想导出AD:AR
导致工作簿崩溃的列中包含的所有公式。
Sub Copyandpaste()
Dim LastRow As Long
Dim ws1 As Worksheet, ws2 As Worksheet
Set ws1 = ActiveWorkbook.Sheets("RAW DATA")
Set ws2 = ActiveWorkbook.Sheets("DATA INPUT")
LastRow = ws1.UsedRange.Rows.Count
With ws2
.Range("A2:AR2" & .Cells(Rows.Count, "G").End(xlUp).Row).Copy Destination:=ws1.Range("A" & LastRow + 1)
For Each WS In ThisWorkbook.Worksheets
For Each PT In WS.PivotTables
PT.RefreshTable
Next PT
Next WS
End With
End Sub