View Single Post
 
Old 01-25-2020, 11:01 AM
BobBridges's Avatar
BobBridges BobBridges is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

So, ElHonigmann, it sounds like you're saying you have some text in a cell in your workbook that contains super- and subscript characters...hm. Let me experiment....

I just put "normal sup sub" into a cell in a scratch worksheet, changed it to 20pt so I could see what's going on, and then recorded a macro changing three of the characters to superscript and three to subscript. The resulting code reads like this:
Code:
    ActiveCell.FormulaR1C1 = "normal sup sub"
    With ActiveCell.Characters(Start:=1, Length:=7).Font
        .Name = "Arial"
        .FontStyle = "Regular"
        .Size = 20
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
        .ThemeFont = xlThemeFontNone
    End With
    With ActiveCell.Characters(Start:=8, Length:=3).Font
        .Name = "Arial"
        .FontStyle = "Regular"
        .Size = 20
        .Strikethrough = False
        .Superscript = True
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
        .ThemeFont = xlThemeFontNone
    End With
    With ActiveCell.Characters(Start:=11, Length:=1).Font
        .Name = "Arial"
        .FontStyle = "Regular"
        .Size = 20
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
        .ThemeFont = xlThemeFontNone
    End With
    With ActiveCell.Characters(Start:=12, Length:=3).Font
        .Name = "Arial"
        .FontStyle = "Regular"
        .Size = 20
        .Strikethrough = False
        .Superscript = False
        .Subscript = True
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
        .ThemeFont = xlThemeFontNone
    End With
Notice that the first statement copied the text from the .Value property to the .FormulaR1C1 property; maybe that's important. Then it set the Font properties not only for the two substrings that I made superscript and subscript, but for the two remaining "normal" substrings too. Again; maybe that's important. Now let's step into a macro and look at the .Characters property of that cell...

No, I can't look at it: "Object doesn't support this property or method". So the reference to ActiveCell.Characters(Start,Length) in the code above is neither a property nor a method. It must be a write-only Sub, returning no value and subject only to change, not to inspection. I'm still "hm"ing to myself. Not sure where to go from here.
Reply With Quote