|
Sub 取数()
Application.ScreenUpdating = False
Dim ar As Variant, br As Variant
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
Dim arr()
With Sheets("2")
ar = .[a1].CurrentRegion
End With
With Sheets("1")
br = .[a1].CurrentRegion
End With
ReDim arr(1 To UBound(br), 1 To UBound(br, 2))
For i = 1 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
d(Trim(ar(i, 1))) = ""
End If
Next i
For i = 1 To UBound(br)
If d.exists(Trim(br(i, 1))) Then
n = n + 1
For j = 1 To UBound(br, 2)
arr(n, j) = br(i, j)
Next j
End If
Next i
If n = "" Then MsgBox "没有需要提取的数据!": End
With Sheets("3")
.[a1].CurrentRegion.Borders.LineStyle = 0
.[a1].CurrentRegion = Empty
.[a1].Resize(n, UBound(arr, 2)) = arr
.[a1].Resize(n, UBound(arr, 2)) = arr
End With
Set d = Nothing
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|