2012-09-15 03:05:46 +0000 2012-09-15 03:05:46 +0000
24
24
Advertisement

Excel:

Advertisement

我是一个完全的Excel新手,所以请原谅我,如果这是很容易做的事情。

基本上,我想删除所有在C列中不包含值的行。

我现在正在为5000多个产品手动操作,这让我很头疼。

Advertisement
Advertisement

答案 (4)

34
34
34
2012-09-15 06:08:10 +0000

如果单元格真的是空白的,你可以很快地完成这个操作,使用SpecialCells

手动*

  • 选择C列
  • F5,然后Special
  • 检查Blanks,然后OK (见底部图片中的步骤)
  • 删除现在选择的行(例如:在选择中右键>删除单元格…>删除单元格或通过色带(见第二张截图) 例如:在选择中右键点击删除单元格…>删除单元格…>整个行或通过功能区(见第二张截图))

VBA*

Sub QuickCull()
    On Error Resume Next
    Columns("C").SpecialCells(xlBlanks).EntireRow.Delete
End Sub

9
9
9
2012-09-15 03:41:57 +0000

这里有一个简单的手动方法

  1. Auto Filter应用到你的表格上
  2. 筛选列C空白
  3. 选择所有可见的行
  4. 删除行 5.删除筛选器

这个过程如果需要,可以用VBA自动完成。试着运行宏记录器来获得一个开始。

0
Advertisement
0
0
2016-02-19 16:18:47 +0000
Advertisement

这个应该能用。

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
-1
-1
-1
2015-03-22 11:48:37 +0000

你可以把这个代码放在工作表模块中(鼠标右键点击工作表选项卡,选择 “查看代码"):

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
Advertisement

相关问题

6
13
9
10
6
Advertisement
Advertisement