|
- Function subscrpt(rng As Range) '数字下标
- Dim cel As Range, reg As Object, mas As Object, ma As Object, txt$
- Set reg = CreateObject("VbScript.RegExp")
- reg.Global = True
- reg.Pattern = "(?:[a-zA-Z\)])(\d+)"
- For Each cel In rng
- txt = cel.Text
- Set mas = reg.Execute(txt)
- With cel
- .Characters.Font.Subscript = False
- .Characters.Font.Superscript = False
- For Each ma In mas
- .Characters(ma.firstindex + 2, ma.Length - 1).Font.Subscript = True
- Next
- End With
- Next
- End Function
- Sub test() '举例
- subscrpt [B2:C27]
- End Sub
复制代码 |
|