- Sub DoDict()
- Dim d As Object, ws As Object
- Dim arr, i As Long, j As Long, s As String, n As Long
- Set d = CreateObject("scripting.dictionary")
- With GetObject(ThisWorkbook.Path & "/系统131.xls")
- arr = .Sheets(1).UsedRange
- .Close False
- End With
- For i = UBound(arr) - 1 To 1 Step -1
- If arr(i, 1) = "" Then arr(i, 1) = arr(i + 1, 1)
- Next
- For i = 1 To UBound(arr)
- If arr(i, 3) <> "" And arr(i, 2) = "" Then n = i
- If n Then
- For j = 3 To UBound(arr, 2)
- s = arr(i, 1) & "," & arr(i, 2) & "," & arr(n, j)
- d(s) = arr(i, j)
- Next
- End If
- Next
- arr = [a1].CurrentRegion
- For i = 2 To UBound(arr)
- If arr(i, 2) = "" Then arr(i, 2) = arr(i - 1, 2)
- For j = 4 To 7
- s = arr(i, 2) & "," & arr(i, 3) & "," & arr(1, j)
- If d.exists(s) Then arr(i, j) = d(s)
- Next
- Next
- [a1].CurrentRegion = arr
- Set d = Nothing
- End Sub
复制代码 |