Answers:
这是一种简单的手动方法
Auto Filter
应用于您的工作表C
空白列上过滤如果需要,可以使用VBA自动执行此过程。尝试运行宏记录器以开始使用
我认为假设您在其他单元格中没有一堆其他公式的最简单方法是按C列对所有内容进行排序,然后删除C列具有空白的所有行(sort函数将放置空白值对于文件顶部的C列)。
综上所述:
这应该工作。
Columns("C:C").Select
Set rngRange = Selection.CurrentRegion
lngNumRows = rngRange.Rows.Count
lngFirstRow = rngRange.Row
lngLastRow = lngFirstRow + lngNumRows - 1
lngCompareColumn = ActiveCell.Column
For lngCurrentRow = lngLastRow To lngFirstRow Step -1
If (Cells(lngCurrentRow, lngCompareColumn).Text = "") Then _
Rows(lngCurrentRow).Delete
Next lngCurrentRow
您可以将以下代码放在工作表模块中(右键单击工作表标签并选择“查看代码”):
Sub Delete_Blank_Rows()
'Deletes the entire row within the selection if the ENTIRE row contains no data.
'We use Long in case they have over 32,767 rows selected.
Dim i As Long
Dim LastRow As Integer
'We turn off calculation and screenupdating to speed up the macro.
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
'Reduce the work on the calc and define the range
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Range("A2:A" & LastRow).Select
'We work backwards because we are deleting rows.
For i = Selection.Rows.Count To 1 Step -1
If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
Selection.Rows(i).EntireRow.Delete
End If
Next i
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub