由于你在这里所做的一切努力,我已经进行了逆向工程并开发了代码,但我已经解决了一件小事。从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
答案 0 :(得分:0)
这是你在尝试的吗?
Sub Copyandpaste()
Dim ws1LRow As Long, ws2LRow As Long
Dim ws1 As Worksheet, ws2 As Worksheet
Set ws1 = ThisWorkbook.Sheets("RAW DATA")
Set ws2 = ThisWorkbook.Sheets("DATA INPUT")
With ws1
ws1LRow = .Cells.Find(What:="*", _
After:=.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row + 1
End With
With ws2
ws2LRow = .Range("G" & .Rows.Count).End(xlUp).Row
.Range("A2:AR" & ws2LRow).Copy
ws1.Range("A" & ws1LRow).PasteSpecial xlPasteValues
' For Each WS In ThisWorkbook.Worksheets
' For Each PT In WS.PivotTables
' PT.RefreshTable
' Next PT
' Next WS
End With
End Sub