可以在Excel中放入数学文本吗?

时间:2019-01-11 13:09:48

标签: excel math text

enter image description here

我想将这样的数学语句(当然是乳胶格式)放入Excel 2016单元格中,就像文本一样。可能吗?如果是这样,该怎么做?

1 个答案:

答案 0 :(得分:1)

尝试一下:

Sub qwerty()
    Dim s As String
    Dim A2 As Range
    Set A2 = Range("A2")
    s = "In the sequence 1, 4, 9, 16, 25, ... each term is a perfect square.  The first term is is 12, the second term is 22, and so on.  A general formula for the nth term of the sequence is un=n2."
    A2 = s
    A2.Characters(Start:=92, Length:=1).Font.Superscript = True
    A2.Characters(Start:=115, Length:=1).Font.Superscript = True
    A2.Characters(Start:=158, Length:=1).Font.FontStyle = "Italic"
    A2.Characters(Start:=185, Length:=1).Font.Subscript = True
    A2.Characters(Start:=188, Length:=1).Font.Superscript = True

End Sub

enter image description here

Character格式遵循VBA标准,而不是乳胶或html标签。