Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim c As Range, i As Long
For Each c In ActiveSheet.UsedRange
If c Like "*+*" Then
i = InStr(c, "+")
c.Characters(i, Len(c) - i + 1).Font.Superscript = True
End If
Next c
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long
If Target <> "" And Target Like "*+*" Then
i = InStr(Target, "+")
Target.Characters(i, Len(Target) - i + 1).Font.Superscript = True
End If
End Sub
用Worksheet_Change事件而不用Workbook_SheetChange事件。也不必循环,直接对发生变化的单元格进行操作。