Tyler
Tyler

Reputation: 616

How do I transpose my current range?

How do I transpose the output in the code below?

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

Upvotes: 0

Views: 36

Answers (1)

L42
L42

Reputation: 19727

It should work. Consider the following example: (can't fit to comment)

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

Applying to your code:

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

Upvotes: 1

Related Questions