|
應該如 2/F, 或直接用工号,
以下代碼須然做到, 但實際是不安全
- Sub zz()
- Dim d As Object, rp As Object, nn$, a, n%
- Dim rrng As Range, rng As Range
- Set d = CreateObject("scripting.dictionary")
- Set rp = CreateObject("vbscript.regexp")
- ar = Sheets(2).[a1].CurrentRegion.Value
- Set rrng = Sheets(2).Range("b2:b" & UBound(ar))
- For i = 2 To UBound(ar)
- d(ar(i, 2)) = ""
- Next
- rp.Pattern = "\s*"
- rp.Global = True
- With Sheets(1)
- ar = .[a1].CurrentRegion.Value
- For i = 3 To UBound(ar)
- k = rp.Replace(ar(i, 1), "")
- If Len(k) Then
- If Not d.exists(k) Then
- .Cells(i, 1).Interior.Color = vbYellow
- For j = 2 To Len(k)
- t = Left(k, 1) & Application.WorksheetFunction.Rept("?", j - 2)
- t = t & Mid(k, j, 1)
- Set rng = rrng.Find(t)
- If Not rng Is Nothing Then .Cells(i, 1) = .Cells(i, 1) & " / " & rng.Value
- Next
- End If
- End If
- Next
- End With
- End Sub
复制代码 |
|