|
Sub 匹配()
Application.ScreenUpdating = False
Dim ar As Variant, br As Variant
Dim i As Long, r As Long, rs As Long, y As Long, ys As Long, j As Long
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("原数据")
rs = .Cells(Rows.Count, 2).End(xlUp).Row
ys = .Cells(6, Columns.Count).End(xlToLeft).Column
ar = .Range(.Cells(6, 2), .Cells(rs, ys))
End With
With Sheets("成果表")
r = .Cells(Rows.Count, 2).End(xlUp).Row
y = .Cells(6, Columns.Count).End(xlToLeft).Column
If r < 7 Then MsgBox "成果表为空!": End
.Range(.Cells(7, 3), .Cells(r, y)) = Empty
br = .Range(.Cells(6, 2), .Cells(r, y))
For i = 2 To UBound(br)
If Trim(br(i, 1)) <> "" Then
d(VBA.Trim(br(i, 1))) = i
End If
Next i
For j = 2 To UBound(br, 2)
If Trim(br(1, j)) <> "" Then
d(VBA.Trim(br(1, j))) = j
End If
Next j
For i = 2 To UBound(ar)
If VBA.Trim(ar(i, 1)) <> "" Then
xh = d(VBA.Trim(ar(i, 1)))
If xh <> "" Then
For j = 2 To UBound(ar, 2)
lh = d(VBA.Trim(ar(1, j)))
If lh <> "" Then
br(xh, lh) = ar(i, j)
End If
Next j
End If
End If
Next i
.Range(.Cells(6, 2), .Cells(r, y)) = br
End With
Set d = Nothing
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
评分
-
1
查看全部评分
-
|