|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。- Sub ykcbf() '//2024.3.18
- Set d = CreateObject("scripting.dictionary")
- With Sheets("Sheet1")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 4)
- End With
- For i = 4 To UBound(arr)
- s = CStr(arr(i, 3))
- d(s) = arr(i, 4)
- Next
- On Error Resume Next
- With Sheets("Sheet2")
- rq1 = .[d3]: rq2 = .[e3]
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 5)
- For i = 5 To UBound(arr)
- For j = 2 To UBound(arr, 2) Step 2
- st = Split(arr(i, j), ",")
- Sum = 0
- For x = 0 To UBound(st)
- If InStr(CStr(st(x)), rq1 & rq2) Then
- Sum = Sum + d(CStr(st(x)))
- End If
- Next
- .Cells(i, j + 1) = Sum
- Next
- Next
- End With
- MsgBox "OK!"
- End Sub
复制代码
|
|