|
练习一下筛选方法
- Sub filterRed()
- Dim sht As Worksheet, rngFilter As Range
- Dim i As Long, lngCount As Long
- With Application
- .ScreenUpdating = False
- .DisplayAlerts = False
- .AskToUpdateLinks = False
- .Calculation = xlCalculationManual
- End With
-
- On Error Resume Next
- Sheets.Add(before:=Sheets(1)).Name = "结果"
- Sheets("结果").Cells.Clear
- If Err.Number Then
- ActiveSheet.Delete
- Err.Clear
- End If
-
- For Each sht In Worksheets
- With sht
- If .Name <> "结果" Then
- With Sheets("结果")
- .Range("a" & lngCount + 1) = sht.Name
- lngCount = .Range("a1").CurrentRegion.Rows.Count
- End With
-
- For i = 2 To .Cells(1, Columns.Count).End(xlToLeft).Column Step 3
- If .AutoFilterMode Then .AutoFilterMode = False
- Set rngFilter = .Range(.Cells(2, i), .Cells(2, i + 1))
- rngFilter.AutoFilter Field:=1, Criteria1:=RGB(255, 0 _
- , 0), Operator:=xlFilterCellColor
- .AutoFilter.Range.SpecialCells(xlCellTypeVisible).Copy Sheets("结果").Range("a" & lngCount + 1)
-
- With Sheets("结果")
- .Rows(lngCount + 1).Delete
- lngCount = .Range("a1").CurrentRegion.Rows.Count
- End With
- Next
- If .AutoFilterMode Then .AutoFilterMode = False
- End If
- End With
- Next
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|