|
楼主 |
发表于 2014-6-28 21:44
|
显示全部楼层
- Sub bxdlbh() '编写电路编号
- On Error Resume Next
- Dim x As String, y As String, z%, x1 As String, y1 As String, z1%, bh, d, bh1
- Set d = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- With Sheets("已有编号数据")
- For z = 2 To .Cells(.Cells.Rows.Count, "b").End(xlUp).Row
- x = .Cells(z, "b") & "-" & .Cells(z, "a")
-
- d(x) = x
- Next
- End With
- With Sheets("sheet1")
- .Columns("a:a").Select
- Selection.NumberFormatLocal = "@"
- For z1 = 2 To .Cells(Cells.Rows.Count, "b").End(xlUp).Row
- .Cells(z1, "a") = 1
- x1 = .Cells(z1, "b") & "-" & .Cells(z1, "a")
- Do While d(x1)
- .Cells(z1, "a") = .Cells(z1, "a") + 1
- x1 = .Cells(z1, "b") & "-" & .Cells(z1, "a")
-
- Loop
- d(x1) = x1
- Next
-
- End With
- Application.ScreenUpdating = True
-
- End Sub
复制代码 |
|