|
改一下。。。
- Sub ykcbf() '//2024.8.20
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("Sheet1")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 8)
- 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(arr(i, 1))
- If Len(st) = 4 Then
- If d.exists(st) Then .Cells(i - 1, 2) = d(st)
- Else
- tt = ""
- s = Left(st, 4)
- If d.exists(s) Then tt = d(s)
- s = Mid(st, 6, 4)
- If d.exists(s) Then tt = tt & Chr(10) & d(s)
- .Cells(i - 1, 2) = IIf(Left(tt, 1) = Chr(10), Mid(tt, 2), tt)
- End If
- End If
- Next
-
- End With
- MsgBox "OK!"
- End Sub
复制代码
|
|