|
Sub 条件选择行()
Dim ar As Variant, br As Variant
Dim rn As Range
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
Set dc = CreateObject("scripting.dictionary")
With Sheets("重复数据")
r = .Cells(Rows.Count, "c").End(xlUp).Row
If r < 3 Then MsgBox "数据源区域为空!": End
ar = .Range("b1:b" & r)
rs = .Cells(Rows.Count, "t").End(xlUp).Row
If rs < 1 Then MsgBox "条件区域为空!": End
br = .Range("t1:t" & rs)
For i = 1 To UBound(br)
If VBA.Trim(br(i, 1)) <> "" Then
dc(VBA.Trim(br(i, 1))) = ""
End If
Next i
For i = 3 To UBound(ar)
If VBA.Trim(ar(i, 1)) <> "" Then
If dc.exists(VBA.Trim(ar(i, 1))) Then
d(VBA.Trim(ar(i, 1))) = d(VBA.Trim(ar(i, 1))) + 1
End If
End If
Next i
For i = 3 To UBound(ar)
If VBA.Trim(ar(i, 1)) <> "" Then
sl = d(VBA.Trim(ar(i, 1)))
If sl = 1 Then
If rn Is Nothing Then
Set rn = .Rows(i)
Else
Set rn = Union(rn, .Rows(i))
End If
End If
End If
Next i
If Not rn Is Nothing Then rn.Select
End With
MsgBox "ok!"
Set d = Nothing
Set dc = Nothing
End Sub
|
|