|
iuriahz 发表于 2013-3-11 21:22
谢谢两位老师赐教,可能是我没把问题陈述清楚,我重新把文件补充一下,你们看下,就是运用代码把1,2.。。。 ...
Sub test()
On Error Resume Next
Dim rng As Range, d As Object, Arr, i&, sht As Worksheet, Shtname
Set d = CreateObject("scripting.dictionary")
Arr = Sheets("Material list").Range("A1").CurrentRegion
For i = 2 To UBound(Arr)
d(Arr(i, 1)) = i
Next
Shtname = Array("Project list", "Material list", "例图")
For Each sht In Worksheets
If sht.Name = "Project list" Or sht.Name = "Material list" Or sht.Name = "例图" Then GoTo 100
For Each rng In sht.Cells.SpecialCells(xlCellTypeConstants)
If d.exists(rng.Value) Then
With Application
rng.Offset(, 1) = .Index(Arr, d(rng.Value), 2)
rng.Offset(, 2) = .Index(Arr, d(rng.Value), 3)
rng.Offset(, 3) = .Index(Arr, d(rng.Value), 4)
With rng.Offset(, 5)
.NumberFormatLocal = "@"
.Value = .Index(Arr, d(rng.Value), 5)
End With
End With
End If
Next
100:
Next
End Sub
|
|