0
我有幾列,我試圖將每列的最後一個單元格複製到一列(在另一個工作表中)。VBA:選擇列範圍中的最後一個單元格並複製工作表中的單元格
這是我的代碼沒有工作,(我是通過行和列循環):
Sub lastcell()
Dim lRow As Long
Dim lCol As Long
Dim i As Long
Worksheets("input").Select
With Worksheets("input")
Worksheets("output").Cells.ClearContents
lCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
Set ColRange = .Range(.Cells(1, 1), .Cells(5, lCol))
For Each ccol In ColRange
lRow = .Cells(.Rows.Count, ccol).End(xlUp).Rows.Count
For i = 2 To 6
Worksheets("output").Cells(i, 1) = .Cells(lRow, ccol)
Next i
Next ccol
End With
End Sub