根据单元格值excelmacros插入下面的行

嗨,我是一个完全新手,但渴望学习。 我在这个论坛上发现了一个基于单元格值插入复制行的macros。 下面的macros在E列中的值为“0”的任何行上面插入一个空行,它几乎帮助我。 而不是行上面出现的空行,我需要它出现在下面。可以帮助我吗? macros代码是:

Sub BlankLine() Dim Col As Variant Dim BlankRows As Long Dim LastRow As Long Dim R As Long Dim StartRow As Long Col = "E" StartRow = 1 BlankRows = 1 LastRow = Cells(Rows.Count, Col).End(xlUp).Row Application.ScreenUpdating = False With ActiveSheet For R = LastRow To StartRow + 1 Step -1 If .Cells(R, Col) = "0" Then .Cells(R, Col).EntireRow.Insert Shift:=xlDown End If Next R End With Application.ScreenUpdating = True End Sub 

编辑以下行:

.Cells(R,Col).EntireRow.Insert Shift:= xlDown

至:

.Cells(R + 1,Col).EntireRow.Insert Shift:= xlDown

与你相关的问题,修改原始代码中的一行:而不是:

 .Cells(R, Col).EntireRow.Insert Shift:=xlDown 

使用这个:

 .Cells(R, Col).EntireRow.Insert Shift:=xlUp 

RGDS,