0
我想用頭名稱選定列移動到一個新的頁面粘貼到連續列開始列A
宏移動列到新的工作表只能移動最後一列
我的宏僅在移動的最後一列
由於
Sub MoveColumnsToNewSheet()
Dim ar As Variant
Dim i As Variant
Dim j As Long
Dim LR As Long
Sheets(1).Select
ar = Array("user name", "Label") ' Find column to copy
LR = Range("A" & Rows.Count).End(xlUp).Row
On Error Resume Next
For i = LBound(ar) To UBound(ar)
j = Rows(1).Find(ar(i), Rows(1).Cells(Rows(1).Cells.Count), , xlWhole, xlByRows).Column
Range(Cells(1, j), Cells(LR, j)).Copy _
Destination:=Worksheets(2).Columns(i)
Next i
On Error GoTo 0
End Sub
感謝您對我的宏的修復,同樣感謝偉大的評論 – xyz
非常歡迎您。快樂的編碼! –
+1以獲得明確的答案和偉大的最佳實踐 –