|
Sub test()
Dim dic As Object
Set dic = CreateObject("Scripting.Dictionary")
arr = Worksheets("数据").Range("a5").CurrentRegion
For i = 2 To UBound(arr)
If Len(arr(i, 8)) Then
Set dic(arr(i, 8)) = CreateObject("Scripting.Dictionary")
For j = 4 To 9
If Len(arr(i, j)) And Not InStr(arr(1, j), "简称") Then dic(arr(i, 8))(arr(1, j)) = arr(i, j)
Next
End If
Next
For Each ff In Worksheets
If InStr(ff.Name, "产量") Then
ff.Select
lastrow = ff.Cells.Find("*", , , , xlByRows, xlPrevious).Row - 1
arr = Range("A5:G" & lastrow)
For i = 2 To UBound(arr)
If Len(arr(i, 6)) Then
If dic.Exists(arr(i, 6)) Then
For j = 1 To 7
If dic(arr(i, 6)).Exists(arr(1, j)) Then
arr(i, j) = dic(arr(i, 6))(arr(1, j))
End If
Next
End If
End If
Next
Range("A5:G" & lastrow) = arr
End If
Next
End Sub
|
|