![我怎样才能在VBA中插入下面的行](https://linux22.com/image/1523483/%E6%88%91%E6%80%8E%E6%A0%B7%E6%89%8D%E8%83%BD%E5%9C%A8VBA%E4%B8%AD%E6%8F%92%E5%85%A5%E4%B8%8B%E9%9D%A2%E7%9A%84%E8%A1%8C.png)
我正在尝试在用户输入下方插入行,但我的代码一直将其添加到上面。谁能告诉我发生了什么......
Dim varUserInput As Variant
varUserInput = InputBox("Enter Row Number where you want to add a row:", _
"What Row?")
If varUserInput = "" Then Exit Sub
RowNum = varUserInput
Rows(RowNum & ":" & RowNum).Insert Shift:=xlDown
答案1
更改xlDown
为xlUp
,如下所示:
Dim varUserInput As Variant
varUserInput = InputBox("Enter Row Number where you want to add a row:", _
"What Row?")
If varUserInput = "" Then Exit Sub
RowNum = varUserInput
Rows(RowNum & ":" & RowNum).Insert Shift:=xlUp*