Transpose a range row

2019-09-12 19:30发布

I am trying to copy the range CW263:DC263 and paste on range CX269:CX294 by vba, but I am getting an error.

I am using a code like that (It may repeat the same in all worksheets):

Sub copiar_colar_reorganizado()

Dim oneRange As Range
Dim aCell As Range
Dim WS_Count As Integer
Dim I As Integer

         ' Set WS_Count equal to the number of worksheets in the active
         ' workbook.
WS_Count = ActiveWorkbook.Worksheets.Count

         ' Begin the loop.
    For I = 1 To WS_Count

Set oneRange = Worksheets(I).Range("CZ269:DA294")
Set aCell = Worksheets(I).Range("DA269")

  Worksheets(I).Range("CW263:DV263").Copy Worksheets(I).Range("CX269:CX294").PasteSpecial(Transpose:=True)


    Next I

End Sub

But I am getting something like: It is not possible to obtain PasteSpecial property from Range class. How to get this?

enter image description here

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-09-12 20:37

Make the Copy paste two lines and remove the () around the transpose:

  Worksheets(I).Range("CW263:DV263").Copy
  Worksheets(I).Range("CX269:CX294").PasteSpecial Transpose:=True

One line is for full copy only not PasteSpecial.

查看更多
登录 后发表回答