|
改一下吧。。。
- Sub ykcbf() '//2024.8.19
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("Sheet1")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 12)
- End With
- For i = 2 To UBound(arr)
- st = Split(arr(i, 4), "-")
- s = st(UBound(st))
- d(s) = arr(i, 4) & arr(i, 6)
- Next
- With Sheets("总表")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 3)
- For i = 2 To UBound(arr)
- If arr(i - 1, 1) = "仓库" Then
- st = CStr(Trim(arr(i, 1)))
- st = Replace(st, ",", " ")
- If Len(st) = 4 Then
- If d.exists(st) Then .Cells(i - 1, 2) = d(st)
- Else
- st = Split(CStr(st))
- For x = 0 To UBound(st)
- s = st(x)
- If d.exists(s) Then .Cells(i - 1, 2) = d(s)
- Next
- End If
- End If
- Next
- End With
- MsgBox "OK!"
- End Sub
复制代码
|
|