我想在现有数据之间添加多行。
我在宏代码下面累了,但是当我添加10行时,它会在每个现有数据之后添加10行。
请帮帮我
Sub test()
Dim j As Long, r As Range
j = InputBox("type the number of rows to be insered")
Set r = Range("A2")
Do
Range(r.Offset(1, 0), r.Offset(j, 0)).EntireRow.Insert
Set r = Cells(r.Row + j + 1, 1)
If r.Offset(1, 0) = "" Then Exit Do
Loop
End Sub
答案 0 :(得分:0)
试试这个简单的代码,
Sub test()
Dim i As Long, j As Long
j = InputBox("type the number of rows to be insered")
For i = 1 To j
Range("A2").EntireRow.Insert
Next i
End Sub