- Sub 生成编码()
- Dim d(6), a(6), ar, arr, sa, s, i
- For i = 0 To 6
- Set d(i) = CreateObject("Scripting.Dictionary")
- Next
- Range("B1:B10000").ClearContents
- Application.ScreenUpdating = False
- ar = Sheet2.UsedRange
- For i = 2 To 10: d(0)(ar(i, 1)) = ar(i, 2): Next
- For i = 2 To 17: d(1)(ar(i, 4)) = ar(i, 5): Next
- For i = 2 To 23: d(2)(ar(i, 7)) = ar(i, 8): Next
- For i = 2 To 5: d(3)(ar(i, 10)) = ar(i, 11): Next
- For i = 10 To 21: d(4)(ar(i, 10)) = ar(i, 11): Next
- For i = 2 To 27: d(5)(ar(i, 13)) = ar(i, 14): Next
- For i = 2 To 13: d(6)(ar(i, 16)) = ar(i, 17): Next
- arr = Sheet1.Range("D9:D18")
- sa = Array(0, 1, 2, 3, 5, 6, 4)
- For i = 0 To 6
- If d(sa(i)).exists(arr(i + 1, 1)) Then a(i) = d(sa(i))(arr(i + 1, 1))
- Next
- s = a(0) & a(1) & a(2) & "18" & a(6) & a(3) & a(4) & a(5) & Format(arr(8, 1), "00")
- For i = 1 To arr(10, 1)
- Cells(i, 2) = s & Format(i, "0000")
- Next
- Application.ScreenUpdating = True
- End Sub
复制代码 |