EXCEL中插入空行,在宏中用什么命令

For i = 15 To 1500 sht1.Activate ✀外循环(表1符合条件的)与表3中不存在的记录比If sht1.Cells(i, 5) = "已授权" Then B1a = sht1.Cells(i, 1)✀取符合条件的记录的序号 sht1.Range("A" & i, "F" & i).Select ✀选中该行 Selection.Copy ✀仅为添加而拷贝(未修改、删除) For j = 15 To1500 ’内循环,表3 sht3.Activate If B1a = sht3.Cells(j, 1) Then ✀序号符合相等条件的为,已存在 Else If B1a > sht3.Cells(j, 1) And B1a < sht3.Cells(j + 1, 1) Then sht3.Cells(j, 1).Activate ✀激活符合条件的单元格 sht3.Cells(j, 1).Select Rows(j + 1).Insert Shift:=xlDown,CopyOrigin:=xlFormatFromLeftOrAbove sht3.Range("A" & j+1, "F" & j+1).Select ActiveSheet.Paste End If End If Next jEnd IfNext i
2026年09月26日 18:13
有3个网友回答
网友(1):

比如要在第三行前插入一行,可以用下面的代码:
SUB 插入一行()
Rows(3).Select
Rows(3).Insert shift:=xlDown
END SUB
运行该代码即可。

网友(2):

选择第5行,插入空行.宏命令如下:

Rows("5:5").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

网友(3):

用宏插入行,应该很局限,自认为完全可以手动