[英]Excel VBA Macro - Copy and insert copied cells
我似乎无法胜任这项工作。 我一直卡在
Rows(rng 5).Select
我想要做的是复制活动单元格的行并将复制的单元格插入活动单元格下方 5 行的行中。
Sub CopyConcatenate()
Dim ws As Worksheet
Dim rng As Range
Set rng = ActiveCell.Rows
rng.Select
Selection.Copy
Rows(rng 5).Select
Selection.Insert Shift:=xlDown
End Sub
未经测试。
这是你正在尝试的吗?
Sub CopyConcatenate()
Dim ws As Worksheet
Dim rng As Range
'~~> Set this to the relevant worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
With ws
'~~> Set your range
Set rng = .Rows(ActiveCell.Row)
'~~> Copy the range
rng.Copy
'~~> Insert the range
rng.Offset(5).Insert Shift:=xlDown
'~~> Clear the clipboard. More importantly remove the
'~~> ant like borders
Application.CutCopyMode = False
End With
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.