|
- Sub 快递大头笔取值对照表()
- Dim R&, Arr, d As Object, x&, Brr, Crr
- Dim R1&, i&, j&, S, S1, Reg, a&, b&, mat, ma, k&
- Application.ScreenUpdating = False
- Set Reg = CreateObject("Vbscript.RegExp")
- Sheet2.Activate
- R = Cells(Rows.Count, 5).End(xlUp).Row
- Arr = Range("a1:f" & R)
- Set d = CreateObject("scripting.dictionary")
- For x = 2 To UBound(Arr)
- If Arr(x, 5) <> "香港" And Arr(x, 5) <> "澳门" And Left(Arr(x, 5), 2) <> "台湾" Then
- If Not d.exists(Arr(x, 5)) Then
- d(Arr(x, 5)) = Arr(x, 6)
- End If
- End If
- Next x
- S = d.keys: S1 = d.items
- Sheet1.Activate
- R1 = Cells(Rows.Count, 1).End(xlUp).Row
- Brr = Range("a1:c" & R1)
- ReDim Crr(1 To UBound(Brr), 1 To UBound(Brr, 2) - 1)
- With Reg
- .Global = True
- .Pattern = ".+(省|市|[^小]区|县|街道办事处|街道办|街道|[^小]区|镇|乡)"
- End With
- For a = 2 To UBound(Brr)
- Set mat = Reg.Execute(Brr(a, 1))
- For Each ma In mat
- k = k + 1
- Crr(k + 1, 1) = ma
- Next ma
- Next a
- For j = 2 To UBound(Crr)
- For i = 0 To d.Count - 1
- If InStr(Crr(j, 1), Mid(S(i), 2, 99)) > 0 Then
- Crr(j, 1) = S(i)
- Crr(j, 2) = S1(i)
- End If
- Next i
- Next j
- [b1].Resize(UBound(Brr), UBound(Brr, 2) - 1) = Crr
- [a1].Resize(1, 3) = Array("地址", "大头笔", "包编号")
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|