|
Sub 按钮1_Click()
Application.ScreenUpdating = False
Dim rnb As Range, rnc As Range
Set d = CreateObject("scripting.dictionary")
Sheets("a").Select
For j = 1 To Cells(Rows.Count, 2).End(3).Row
If Len(Cells(j, 2)) > 0 Then
d(Cells(j, 2).Value) = ""
' For i = 1 To Cells(Rows.Count, "j").End(3).Row
' If Cells(j, 2) = Cells(i, "j") Then
' If rnb Is Nothing Then
' Set rnb = Cells(i, 1)
' Else
' Set rnb = Union(rnb, Cells(i, 1))
' End If
' End If
' Next i
End If
Next j
For i = 1 To Cells(Rows.Count, "j").End(3).Row
If d.exists(Cells(i, "j").Value) Then
If rnb Is Nothing Then
Set rnb = Cells(i, 1)
Else
Set rnb = Union(rnb, Cells(i, 1))
End If
End If
Next i
If Not rnb Is Nothing Then rnb.EntireRow.Copy Sheets("b").Cells(1, 1)
For j = 1 To Cells(Rows.Count, 3).End(3).Row
If Len(Cells(j, 3)) > 0 Then
For i = 1 To Cells(Rows.Count, "k").End(3).Row
If Cells(j, 3) = Cells(i, "k") Then
If rnc Is Nothing Then
Set rnc = Cells(i, 1)
Else
Set rnc = Union(rnc, Cells(i, 1))
End If
End If
Next i
End If
Next j
If Not rnc Is Nothing Then rnc.EntireRow.Copy Sheets("c").Cells(1, 1)
Application.ScreenUpdating = True
End Sub
|
|