将2行添加到现有的macros

下面是我现在使用的macros..编辑细节在底部。

Sub AddBlankRows() ' Dim iRow As Integer Range("a1").Select ' iRow = 1 ' Do ' If Cells(iRow + 1, 1) <> Cells(iRow, 1) Then Cells(iRow + 1, 1).EntireRow.Insert shift:=xlDown iRow = iRow + 2 Else iRow = iRow + 1 End If ' Loop While Not Cells(iRow, 2).Text = "" ' End Sub 

上面的macros,我发现(谷歌search)Stackoverflows问题之一,有人问了,它为我的目的工作。 然而,我无法find它提供的信息来自哪个问题。

我现在正在使用它,并且工作得很好。 不过,我需要添加更多的行。 所以我必须手动插入行,因为我需要他们。 我想让macros为我做。 而不是每个分组的单元格后添加1行。 我需要添加2行。 有人可以帮我编辑上面的macros,让它给我2行而不是1行。

另外,我需要根据列E中的数据来分隔行,而不是A,我一直在寻找几个小时,用编码弄瞎了,但是我不能使它工作,我是相当新的这个还在学习。

这是我的第一篇文章,并提前感谢大家。

我不太清楚你真正想用这个macros来达到什么目的,但是在这里我是这样做的:

 Sub AddBlankRows() Dim iRow As Integer Dim iCol As Integer iRow = 1 ' Row 1 iCol = 5 ' Column E Do If Cells(iRow + 1, iCol) <> Cells(iRow, iCol) Then Range(Cells(iRow + 1, iCol), Cells(iRow + 2, iCol)).EntireRow.Insert shift:=xlDown iRow = iRow + 3 Else iRow = iRow + 1 End If Loop While Not Cells(iRow, iCol + 1).Text = "" End Sub