删除特定的单元格Excel

我想要做的是程序经过是从一个单元格列中find一个确定的值,看看它是否与一个单元格匹配后,我特别粘贴的价值,如果有一个匹配删除关联的单元格和它的一排细胞。 发生的事情是该程序的特殊粘贴部分正在工作,但关联的单元格不被删除。 为了澄清,我试图根据是否有匹配从某个列中删除整行

Dim j As Integer Dim i As Integer i = 2 Dim Aud_Tot As Integer Aud_Tot = Application.InputBox("How big is your audit", , , , , , , 1) Do While True If Cells(i, 1).Value <> "" And Not IsError(Cells(i, 2).Value) Then Range(Cells(i, 1), Cells(i, 22)).Copy Range(Cells(i, 1), Cells(i, 22)).PasteSpecial xlPasteValues For j = 2 To Aud_Tot If Cells(j, 24).Value = Cells(i, 2).Value Then Range(Cells(j, 24), (Cells(j, 42))).ClearContents End If Next j i = i + 1 Else Exit Do End If Loop 

看来你想删除行,但你只使用ClearContents 。 要删除,可以将该行更改为Range(Cells(j, 24), (Cells(j, 42))).Delete Shift:=xlShiftUp ,也可以使用xlShiftToLeft

你想删除行还是只删除你的范围?

Interesting Posts