|
参与一下。。。- 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
复制代码
|
|