excel 每间隔一行插入行

来源:百度知道 编辑:UC知道 时间:2024/06/08 03:08:13
我编辑一表格编号不同,要求不同编号之间插入一空行,请问如何做?

这个用不着那么麻烦,你在后面加入一列,假设你有十列,你就在后面一次输入1到10,然后在复制这些数字,粘贴在后面,然后对这一列排序就可以了,排序玩你就可以把后面那列数据删除就可以了,你试试看

编写宏吧,工具-宏-宏编辑器-插入-模块-双击左窗口模块1-窗口右侧粘贴如下代码。
Sub gzt()
Dim Irow As Integer, Icol As Integer
Application.ScreenUpdating = False
Irow = [A1].CurrentRegion.Rows.Count
a = (Irow - 1) * 2
Icol = [A1].CurrentRegion.Columns.Count
For i = 2 To a Step 2
If Cells(i, 1) <> "" And Cells(i + 1, 1) <> "" Then
Rows(i + 1).Insert
End If
If Cells(i, 1) <> "" And Cells(i + 1, 1) = "" Then
Range(Cells(1, 1), Cells(1, Icol)).Copy Cells(i + 1, 1)
End If
Next i
Range("A1").Select
Application.ScreenUpdating = True
End Sub

鼠标移至最左,两行之间右击插入