如果单元格真的是空白的,你可以很快地完成这个操作,使用SpecialCells
手动*
F5
,然后Special
Blanks
,然后OK
(见底部图片中的步骤) VBA*
Sub QuickCull()
On Error Resume Next
Columns("C").SpecialCells(xlBlanks).EntireRow.Delete
End Sub
这里有一个简单的手动方法
Auto Filter
应用到你的表格上C
空白这个过程如果需要,可以用VBA自动完成。试着运行宏记录器来获得一个开始。
这个应该能用。
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