您好我已经尝试制作一个可以插入x行的宏但它不起作用。 我会非常感谢任何帮助! :)
Sub Makro4()
'
' Makro4 Makro
'
' Kortkommando: Ctrl+j
'
Dim Rng
Dim k
Rng = InputBox("Enter number:.")
For Rng = k To Rng
k = k + 1
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Exit For
Next
End Sub
答案 0 :(得分:1)
Sub Makro4()
Dim Rng As Integer
Dim k As Integer
Dim rRange As Range
Set rRange = Selection
Rng = InputBox("Enter number:.")
For k = 1 To Rng
Rows(rRange.Row).Insert Shift:=xlDown, _
CopyOrigin:=xlFormatFromLeftOrAbove
Next
End Sub
你的for循环没有意义,你退出它所以它总是只插入一行。我修复了它并展示了如何插入行。