|
本帖最后由 ggmmlol 于 2018-6-19 19:49 编辑
- Sub test()
- Dim br(1 To 9999, 1 To 3)
- Set rg = CreateObject("vbscript.regexp")
- rg.Global = True
- r = Cells(Rows.Count, "J").End(xlUp).Row
- ar = Range("H2:J" & r)
- For i = 2 To r - 1
- rg.Pattern = " *[一-隝]+ *"
- tmp = Split(rg.Replace(ar(i, 3), ""), "/")
- rg.Pattern = "\+(\w+)?(\((\d+)\))?"
- For j = 0 To UBound(tmp)
- s = Trim(tmp(j)) & " "
- p = InStr(s, " ")
- xh = Left(s, p)
- gg = "+" & Mid(s, p + 1)
- Set mas = rg.Execute(gg)
- For Each ma In mas
- Set smas = ma.submatches
- n = n + 1
- br(n, 1) = ar(i, 1)
- br(n, 2) = smas(2)
- If Len(br(n, 2)) = 0 Then br(n, 2) = 1
- br(n, 3) = Trim(xh & smas(0))
- If br(n, 2) > 1 Then br(n, 1) = br(n, 1) & " X " & br(n, 2)
- Next
- Next
- Next
- [A3].Resize(9999, 3) = br
- End Sub
复制代码 |
|