如何在下面的代码中转置输出?
Dim lastRow As Range, rng1 As Range
Set rng1 = Worksheets(1).Range("I80:I83")
Set lastRow = ThisWorkbook.Worksheets("Sheet1").Cells(ThisWorkbook.Worksheets("Sheet1").Rows.Count, "B").End(xlUp)
lastRow.Offset(1, 0).Resize(rng1.Rows.Count, rng1.Columns.Count) = rng1.Value
答案 0 :(得分:1)
它应该工作。请考虑以下示例:(不适合评论)
With Sheet1 '/* or what ever your sheet object is */
.Range("A1") = 1
.Range("A2") = 2
.Range("A3") = 3
.Range("C1:E1") = Application.Transpose(.Range("A1:A3"))
End With
申请代码:
Dim lastRow As Range, rng1 As Range
With Thisworkbook.Sheets(1)
Set rng1 = .Range("I80:I83")
Set lastrow = .Range("B" & .Rows.Count).End(xlUp)
lastrow.Offset(1, 0).Resize(rng1.Columns.Count, rng1.Rows.Count) = rng1.Value
End With