- ©«¤l
- 262
- ¥DÃD
- 8
- ºëµØ
- 0
- ¿n¤À
- 280
- ÂI¦W
- 17
- §@·~¨t²Î
- xp
- ³nÅ骩¥»
- Office 2007
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- HK
- µù¥U®É¶¡
- 2015-8-11
- ³Ì«áµn¿ý
- 2024-11-19
|
·PıÆZ½ÆÂø:- Sub zz()
- Dim a, b, c(), n&, d As Object, re As Object, aa(), xt As Boolean
- Dim dd As Object, s$, p, z(1)
- Set re = CreateObject("vbscript.regexp")
- Set d = CreateObject("scripting.dictionary")
- Set dd = CreateObject("scripting.dictionary")
- With Sheets(2)
- a = .Range("b2:i" & .[b1048576].End(3).Row)
- End With
- Application.StatusBar = "Program processing... please wait"
- With re
- .Pattern = "(\d+-?\d*)"
- .Global = True
- For i = 1 To UBound(a)
- d(a(i, 1)) = i
- If .test(a(i, 1)) Then
- k = Split(.Replace(a(i, 1), "|$1|"), "|")
- n = Val(k(UBound(k) - 1))
- s = ""
- For j = 0 To UBound(k) - 2 Step 2
- s = s & k(j)
- Next
- If dd.exists(s) Then
- p = dd(s)
- ReDim Preserve p(UBound(p) + 1)
- p(UBound(p)) = n & "|" & i
- dd(s) = p
- Else
- dd(s) = Array(n & "|" & i)
- End If
- End If
- Next
- End With
- For Each k In dd.keys
- p = dd(k)
- ReDim b(UBound(p), 1)
- For j = 0 To UBound(p)
- t = Split(p(j), "|")
- b(j, 0) = Val(t(0))
- b(j, 1) = Val(t(1))
- Next
- For i = 0 To UBound(b) - 1
- t = b(i, 0)
- For j = i + 1 To UBound(b)
- If b(j, 0) < t Then t = b(j, 0): jj = j: xt = True
- Next
- If xt Then
- xt = False
- For j = 0 To 1
- z(j) = b(i, j)
- b(i, j) = b(jj, j)
- b(jj, j) = z(j)
- Next
- End If
- Next
- dd(k) = b
- Next
- With Sheets(1)
- b = .Range("b2:b" & .[b1048576].End(3).Row)
- .Cells(2, "h").Resize(UBound(b), 3).Clear
- ReDim c(1 To UBound(b), 1 To 3)
- For i = 1 To UBound(b)
- Application.StatusBar = "Finised " & i & " of " & UBound(b)
- n = d(b(i, 1))
- If n Then
- c(i, 1) = a(n, 7): c(i, 2) = a(n, 8)
- Else
- c(i, 3) = "¼Ò½k¤ñ¹ï"
- GoSub FC
- If dd.exists(s) Then
- p = dd(s)
- If n Then
- If UBound(p) Then
- If n < p(0, 0) Then n = p(0, 0)
- n = Application.VLookup(n, dd(s), 2, 1)
- Else
- n = dd(s)(0, 1)
- End If
- c(i, 1) = a(n, 7): c(i, 2) = a(n, 8)
- End If
- End If
- End If
- Next
- Cells(2, "H").Resize(i - 1, 3) = c
- End With
- Debug.Print dd.Count
- Application.StatusBar = False
- End
- FC:
- With re
- If .test(b(i, 1)) Then
- k = Split(.Replace(b(i, 1), "|$1|"), "|")
- n = Val(k(UBound(k) - 1))
- s = ""
- For j = 0 To UBound(k) - 2 Step 2
- s = s & k(j)
- Next
- End If
- End With
- Return
- End Sub
½Æ»s¥N½X |
|