如果同一行中的另一个单元格为空,则清除行中的单元格

如果在G列中find空单元格,此代码将删除整行。如果列G中的单元格为空,则需要清除列A中的单元格。

On Error Resume Next ' In case there are no blanks Columns("G:G").SpecialCells(xlCellTypeBlanks).EntireRow.Delete ActiveSheet.UsedRange 'Resets UsedRange for Excel 97 

尝试这个:

 With Intersect(Columns("G:G"), ActiveSheet.UsedRange) If WorksheetFunction.CountBlank(.Cells) > 0 Then .SpecialCells(xlCellTypeBlanks).Offset(, -6).ClearContents End If End With 

试试这个。

 Columns("G:G").SpecialCells(xlCellTypeBlanks).Offset(0,-6).ClearContents 

像这样:

 On Error Resume Next ' In case there are no blanks Columns("G:G").SpecialCells(xlCellTypeBlanks).Offset(, -6) = ""