|
代码供参考。。。- Sub ykcbf() '//2024.2.16
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- Set reg = CreateObject("VBScript.RegExp")
- Set List = CreateObject("System.Collections.ArrayList")
- r = Me.Cells(Rows.Count, 1).End(3).Row
- arr = Me.Range("a1:b" & r)
- ReDim brr(1 To 1000, 1 To 20)
- With reg
- .Global = True
- .Pattern = "([a-zA-Z]+\d+)|(\d+)|([\u4e00-\u9fa5]+)"
- End With
- For i = 2 To UBound(arr)
- st = arr(i, 1)
- Set mh = reg.Execute(st)
- s = mh(0).Value & "|" & mh(1).Value
- d1(s) = ""
- ss = s & "|" & mh(2).Value
- d(ss) = d(ss) + arr(i, 2)
- s2 = mh(2).Value
- If Not List.Contains(s2) Then List.Add s2
- Next
- List.Sort
- For Each k In d1.keys
- m = m + 1
- brr(m, 1) = Split(k, "|")(0)
- brr(m, 2) = Split(k, "|")(1)
- Next
- With Sheets("Sheet2")
- .UsedRange.Offset(2).Clear
- .[c2:z2].Clear
- .[c1:z1].UnMerge
- .Columns(1).NumberFormatLocal = "@"
- .[c2].Resize(1, List.Count) = List.toArray
- .[a3].Resize(m, 2) = brr
- .[c1].Resize(1, List.Count).Merge
- .UsedRange.Borders.LineStyle = 1
- arr = .UsedRange
- For i = 3 To UBound(arr)
- For j = 3 To List.Count + 2
- s = arr(i, 1) & "|" & arr(i, 2) & "|" & arr(2, j)
- If d.exists(s) Then
- arr(i, j) = d(s)
- End If
- Next
- Next
- .UsedRange = arr
- End With
- Set d = Nothing
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|