|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub Main()
- Dim d As New Dictionary
- '字典d实现工序名称和单价的VLOOKUP
- ar = Sheet1.UsedRange.Value
- ReDim br(1 To UBound(ar) * 10, 1 To 4)
- For i = 2 To UBound(ar)
- pinhao = ar(i, 1)
- For k = 2 To UBound(ar, 2) Step 2
- gongxu = ar(i, k)
- danjia = ar(i, k + 1)
- If Len(gongxu) > 0 And Len(danjia) > 0 Then
- j = j + 1
- br(j, 1) = pinhao
- br(j, 2) = gongxu
- br(j, 3) = d(gongxu) '代码
- br(j, 4) = danjia
- End If
- Next
- Next
- With Sheet2
- .UsedRange.Offset(1).ClearContents
- .Range("A2").Resize(j, 4).Value = br
- End With
- End Sub
复制代码 |
|