转置范围行 [英] Transpose a range row
本文介绍了转置范围行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试复制范围CW263:DC263并通过vba粘贴在范围CX269:CX294上,但出现错误.
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
但是我得到了类似的东西:无法从Range类获得PasteSpecial属性.如何获得?
But I am getting something like: It is not possible to obtain PasteSpecial property from Range class. How to get this?
推荐答案
进行复制粘贴两行,并删除转置周围的()
:
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
一行仅用于完整复制,不用于PasteSpecial.
One line is for full copy only not PasteSpecial.
这篇关于转置范围行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文