首页 > 解决方案 > 使用 VB 模块在 MS Excel 中重复行

问题描述

我在 MS Excel 中使用这个 VBA 片段,它允许我通过在弹出对话框中输入的“X”数字复制行。我想改变它,使它只重复第 3、5、7 行等,但不重复第 1 行。

Sub insertrows()
Dim I As Long
Dim xCount As Integer
LableNumber:
xCount = Application.InputBox("Number of Rows", "Popup menu", , , , , , 1)
If xCount < 1 Then
MsgBox "The entered number of rows is error ,please enter again"
GoTo LableNumber
End If
For I = Range("A" & Rows.CountLarge).End(xlUp).Row To 2 Step -1
Rows(I).Copy
Rows(I).Resize(xCount).Insert
Next
Application.CutCopyMode = False
End Sub

标签: excelvba

解决方案


推荐阅读