我有其他人制作的以下宏:
Sub test2()
Dim n As Integer, rng As Range
'n = InputBox("type the value of n")
Set rng = Range("a1")
rng.Select
line2:
n = InputBox("type no. of times you want to be repeated minus 1 for e.g if you wnat to be repeated 3 times type 2")
Range(rng.Offset(1, 0), rng.Offset(n, 0)).EntireRow.Insert
Range(rng, rng.End(xlToRight)).Copy
Range(rng, rng.Offset(n, 0)).PasteSpecial
Set rng = rng.Offset(n + 1, 0)
If rng = "" Then
GoTo line1
Else
GoTo line2
End If
line1:
Application.CutCopyMode = False
Range("a1").Select
MsgBox "macro over"
Stop
End Sub
我希望范围选择是动态的,即在上面的代码中,它被硬编码为“a1”,但由于我想一次又一次地重复宏,我想每次都通过鼠标单击来选择不同的起点。
此外,当我完成复制单元格时,它会重新启动,并且一旦我复制了一次宏,我想停止它。然后选择新的起点选择一行然后复制它 x # 次
提前感谢您的帮助