1
我希望下面的代碼可以在工作簿上的所有(20)工作表上工作,但它只能在1張工作表上工作,並且在該工作表上反覆複製/粘貼,有什麼建議嗎?loop all sheet-not working,only re performed on single sheets
非常感謝您的時間
Sub Copylastcolumn()
Dim ws As Worksheet
On Error Resume Next
For Each ws In ThisWorkbook.Worksheets
Dim LastRow As Long
Dim LastCol As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
LastCol = Cells(6, "BJ").End(xlToLeft).Column
Cells(6, LastCol).Resize(LastRow - 5).Copy Cells(6, LastCol + 1)
Columns(LastCol).Copy
Columns(LastCol).PasteSpecial xlPasteValues
Next ws
End Sub