|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。
- Sub ykcbf() '//2024.4.17
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- p = ThisWorkbook.Path
- f = p & "\发票导出信息.xlsx"
- Set ws = ThisWorkbook
- Set sh = ws.Sheets("销售订单")
- arr = ws.Sheets("商品名对应关系").UsedRange
- For i = 1 To UBound(arr)
- s = arr(i, 2)
- d1(s) = arr(i, 1)
- Next
- arr = ws.Sheets("客户对应关系").UsedRange
- For i = 1 To UBound(arr)
- s = arr(i, 2)
- d1(s) = arr(i, 1)
- Next
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets(1)
- arr = .UsedRange
- wb.Close False
- End With
- For i = 2 To UBound(arr)
- s = d1(arr(i, 2)) & "|" & d1(arr(i, 3))
- If Not d.exists(s) Then
- d(s) = Array(arr(i, 1), arr(i, 4))
- End If
- Next
- ReDim brr(1 To 1000, 1 To 8)
- On Error Resume Next
- With sh
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 8)
- For i = 2 To UBound(arr)
- s = arr(i, 3) & "|" & arr(i, 5)
- m = m + 1
-
- brr(m, 1) = d(s)(0)
- For j = 1 To UBound(arr, 2) - 1
- brr(m, j + 1) = arr(i, j)
- Next
- If brr(m, 1) = Empty Then
- brr(m, 8) = "未查到对应客户发票号"
- End If
- Next
- End With
- With ws.Sheets("提取后效果示例")
- .UsedRange.Offset(1) = ""
- .Columns(1).NumberFormatLocal = "@"
- .[a2].Resize(m, 8) = brr
- End With
- Set d = Nothing
- Set d1 = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|