我已經反向工程,並開發了一個代碼感謝您在這裏的所有努力,但我已經擺脫了一件小事。從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
您提到'AD:AR',但代碼中說'A:AR'? – 2013-04-04 09:41:48
添加.Value? Destination:= ws1.Range(「A」&LastRow + 1).Value – 2013-04-04 09:43:35
這裏有一些問題:'.Range(「A2:AR2」&.Cells(Rows.Count,「G」)。End(xlUp) .Row)'。請檢查它... – 2013-04-04 10:09:29