宏的新手,我需要一个代码来复制几行并在同一张纸上插入复制的单元格到下面的几行
也许我没有正确解释自己 插入的复制行需要推送行11,12和13(3行并插入复制的行)而不是替换 干杯银色
我们几乎在那里,我需要插入的复制行需要相应地推送行10-13,即10行以下的每一行都需要插入复制的行 干杯银色
答案 0 :(得分:0)
假设,我已经猜到了你需要的东西:)
Sub Test()
Dim rng As Range
Dim height As Integer
Dim startRowToPaste As Integer
Dim countOfPaste As Integer
Dim startIndex As Integer
Set rng = Range("3:6")
height = rng.Rows.Count
startRowToPaste = 7 ' num of first row at witch need to paste
countOfPaste = 8 ' count of times you want to paste
For i = startRowToPaste To startRowToPaste + countOfPaste - 1
'determining num of row where need to paste values
startIndex = startRowToPaste + (i - startRowToPaste) * (height + 1) + 1
'insert new rows
Rows(startIndex & ":" & startIndex + height - 1).Insert Shift:=xlDown
'paste values
rng.Copy Destination:=Range(startIndex & ":" & startIndex + height - 1)
Next i
End Sub