H2O, m2, x2)。H2O 中的 2)。



Sub FormatSubscript()
' 將選取區域所有儲存格的第 2 個字元設為下標
Dim c As Range
For Each c In Selection
If Len(c.Value) >= 2 Then
c.Characters(Start:=2, Length:=1).Font.Subscript = True
End If
Next c
End Sub
Sub FormatSuperscript()
Dim c As Range
For Each c In Selection
If Len(c.Value) >= 2 Then
c.Characters(Start:=2, Length:=1).Font.Superscript = True
End If
Next c
End Sub
適用於大量化學式(H2O、CO2)、數學式(x2、m3)批次處理。