|
- Sub qs()
- Dim arr, i, rg As Range, rg2 As Range, dic As Object
- Set dic = CreateObject("scripting.dictionary")
- With Sheet4
- x = Application.InputBox("请输入数字【 1 】按姓名筛选输入数字【 2 】按身份证号筛选")
- If x = 1 Then
- c = 3
- c2 = 30
- ElseIf x = 2 Then
- c = 4
- c2 = 31
- Else
- Exit Sub
- End If
- 取消筛选
- RO = .Cells(Rows.Count, c).End(3).Row
- RO2 = .Cells(Rows.Count, c2).End(3).Row
- arr = .Range(.Cells(3, c), .Cells(RO, c))
- Set rg = .Range(.Cells(3, c), .Cells(RO, c))
- Set rg2 = .Range(.Cells(3, c2), .Cells(RO2, c2))
- Set rg = Union(rg, rg2)
- For Each r In rg
- If r.Value <> "" Then
- If Not dic.exists(r.Value) Then
- dic(r.Value) = 1
- Else
- dic(r.Value) = dic(r.Value) + 1
- End If
- End If
- Next
- For i = 1 To UBound(arr)
- If dic(arr(i, 1)) = 1 Then
- .Rows(i + 2).Hidden = True
- End If
- Next
- End With
- Set dic = Nothing: Set rg = Nothing: Set rg2 = Nothing
- End Sub
- Sub 取消筛选()
- Sheet4.Rows("1:200").Hidden = False
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|