Excel VBA 宏 - 复制和插入复制的单元格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21455635/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 17:40:12 来源:igfitidea点击:
Excel VBA Macro - Copy and insert copied cells
提问by NoNo
I can't seem to make to this work. I keep getting stuck on
我似乎无法胜任这项工作。我一直卡在
Rows(rng 5).Select
What I am trying to do is copy the row of the active cell and inserting the copied cell in a row that is 5 rows below the active cell.
我想要做的是复制活动单元格的行并将复制的单元格插入活动单元格下方 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
回答by Siddharth Rout
Untested.
未经测试。
Is this what you are trying?
这是你正在尝试的吗?
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