VBA:转置最后一行

时间:2016-07-12 13:43:34

标签: excel vba transpose

我正在尝试转置电子表格的最后一行,使其成为一个列。

我已经开始检索电子表格的最后一列/行号,但我不知道如何将其设为数组以使用Application.transpose(myarray)Application.WorksheetFunction.Transpose(myarray)转换它

Dim lRow As Long, lCol As Long
lRow = Cells(Rows.Count, 1).End(xlUp).Row
lCol = Cells(1, Columns.Count).End(xlToLeft).Column

任何提示?

由于

1 个答案:

答案 0 :(得分:1)

从:

开始

enter image description here

运行:

Sub xPose()
    Dim r As Range, N As Long
    N = Cells(Rows.Count, "A").End(xlUp).Row
    Set r = Cells(N, 1).EntireRow

    r.Copy
    Cells(N + 1, 1).PasteSpecial Transpose:=True
    r.Delete
End Sub

将产生:

enter image description here