如何在大型电子表格中的特定单元格之前插入空行?

时间:2014-01-21 11:07:51

标签: excel vba excel-vba

我有一个大型电子表格,大约有200,000行,我想在每100个序列号之后插入一行,但不是按行号

我找到了一个按行号插入的宏,但这不是我想要的。

1 个答案:

答案 0 :(得分:1)

我认为你的意思是:

Dim theRange As Range
Dim idx As Long

Set theRange = Sheet1.UsedRange ''Or other appropriate sheet
idx = Range("A" & Rows.Count).End(xlUp).Row ''Where A is your serial number

For i = idx To 1 Step -1

    If theRange.Cells(i, 1) Mod 100 = 0 Then
       Rows(i).Insert shift:=xlShiftDown
    End If

Next
相关问题