|
在 模块1 添加以下宏,运行它可以在整个工作薄中搜索“计算式”所在的列,并把其计算式中的注释内容下标
- Sub 注释批量下标()
- Dim exp$, i&, matches, ma, Sh As Worksheet, Target As Range
- Set reg = CreateObject("vbscript.regexp")
- reg.Global = True
- reg.Pattern = "\[.*?\]|{(.*?)}|[^0-9.+-/^*()]"
- For Each Sh In Sheets
- For c = 1 To Sh.UsedRange.Columns.Count
- For i = 1 To 3
- If InStr(Sh.Cells(i, c), "计算式") Then
- For j = i + 1 To Sh.UsedRange.Rows.Count
- exp = Sh.Cells(j, c).Value
- Set matches = reg.Execute(exp)
- With Sh.Cells(j, c).Font
- .Superscript = False
- .Subscript = False
- .ColorIndex = 0
- End With
- For Each ma In matches
- With Sh.Cells(j, c).Characters(1 + ma.firstindex, ma.Length).Font
- .Subscript = True
- .Color = vbBlue
- End With
- Next
- Next
- Exit For
- End If
- Next
- Next
- Next
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|