|
Sub 匹配格式()
Application.ScreenUpdating = False
Dim ar As Variant
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
Set sh = Sheet1
With sh
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r < 2 Then MsgBox "sheet1为空!": End
ar = .Range("a1:a" & r)
For i = 1 To UBound(ar)
If ar(i, 1) <> "" Then
d(ar(i, 1)) = i
End If
Next i
End With
With Sheet2
rs = .Cells(Rows.Count, 1).End(xlUp).Row
If rs < 2 Then MsgBox "sheet2为空!": End
ar = .Range("a1:a" & r)
For i = 1 To UBound(ar)
If ar(i, 1) <> "" Then
xh = d(ar(i, 1))
If xh <> "" Then
sh.Rows(xh).Copy
.Rows(i).PasteSpecial Paste:=xlPasteFormats
End If
End If
Next i
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|