Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 如何在大型电子表格中的特定单元格前插入空行?_Vba_Excel - Fatal编程技术网

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

Vba 如何在大型电子表格中的特定单元格前插入空行?,vba,excel,Vba,Excel,我有一个大的电子表格,大约200000行,我想在每100个序列号后面插入一行,但不是按行号 我找到了一个按行号插入的宏,但这不是我想要的。我想你的意思是: 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

我有一个大的电子表格,大约200000行,我想在每100个序列号后面插入一行,但不是按行号

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

我想你的意思是:

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

一个好的开始是你发布那个宏。在这里,我发现那个宏,,,谢谢你,先生,这样做只会在第一列中插入一行,但我想在该点(101行之前)为所有列插入一个空行。我已更改为插入一整行。@user1917229请不要根据提供的答案编辑标记。答案可能表明使用/不使用早期绑定,但原始标签适用于