|
发表于 2012-4-6 21:57
|
显示全部楼层
本楼为最佳答案
做了d至j列,可数字不一样
用了字典,要引用
Sub test()
Dim d1 As New Dictionary, d2 As New Dictionary
Dim ar1(), ar()
With Sheets("sheet1")
i% = .[a65536].End(xlUp).Row
ar1 = .Range("a2:j" & i).Value
End With
For i = 3 To UBound(ar1)
d1("" & ar1(i, 1)) = i
Next
For i = 4 To UBound(ar1, 2)
d2("" & ar1(1, i)) = i
Next
With Sheets("sheet3")
i = .[a65536].End(xlUp).Row
ar = .Range("a9:a" & i).Value
End With
For i = 1 To UBound(ar)
If InStr(ar(i, 1), ":") < 1 And InStr(ar(i, 1), ".") > 4 Then
ar(i, 1) = Trim(ar(i, 1))
artmp = Split(Split(ar(i, 1), " ")(0), ".")
If d1.Exists(artmp(0)) And d2.Exists(artmp(1)) Then
Do While InStr(ar(i, 1), " ")
ar(i, 1) = Replace(ar(i, 1), " ", " ")
ar(i, 1) = Replace(ar(i, 1), " ", " ")
Loop
artmp2 = Split(ar(i, 1), " ")
ar1(d1(artmp(0)), d2(artmp(1))) = artmp2(UBound(artmp2))
End If
End If
Next
Sheets("sheet1").Range("a17").Resize(UBound(ar1), UBound(ar1, 2)) = ar1
End Sub |
|