选择特定行并粘贴它的转置

时间:2015-10-30 13:53:40

标签: excel excel-vba vba

我需要从工作表中复制特定行并将其转置粘贴到不同的工作表中 如果有人向我提供宏代码,那就太好了。

1 个答案:

答案 0 :(得分:1)

您可以使用宏录制器来实现这一点,非常简单:

Sub test()
Dim ws1 as Worksheet, ws2 as Worksheet
Dim rng As Range, destRng As Range
Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
Set rng = ws1.Range("A1:A10")
Set destRng = ws2.Range("B1:K1")

rng.Copy
destRng.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True

End Sub