Hi there, pretty new to macros and VBA, but I'm fairly confident this is strange behaviour.
I wrote a little macro to toggle the last letter of the selected cell to superscript, to help make m^2 easier to format. I've pasted it below and it works perfectly.
Only thing is, I went to do the same for subscript, also pasted below, and it'll turn it to subscript but won't turn it back to normal again. It's like subscript = FALSE behaves differently to .superscript = FALSE. Anyone got an idea why?
Cheers!
Sub SuperScrLastChar()
Sub SubScrLastChar()
I wrote a little macro to toggle the last letter of the selected cell to superscript, to help make m^2 easier to format. I've pasted it below and it works perfectly.
Only thing is, I went to do the same for subscript, also pasted below, and it'll turn it to subscript but won't turn it back to normal again. It's like subscript = FALSE behaves differently to .superscript = FALSE. Anyone got an idea why?
Cheers!
Sub SuperScrLastChar()
'Turn last character in string to superscript
With Selection.Characters(Start:=Len(ActiveCell.Value), Length:=1).Font
If .Superscript = False Then
.Superscript = True
Else
.Superscript = False
End If
End With
End SubSub SubScrLastChar()
' Turn last character in string to subscript
With Selection.Characters(Start:=Len(ActiveCell.Value), Length:=1).Font
With Selection.Characters(Start:=Len(ActiveCell.Value), Length:=1).Font
If .Subscript = False Then
.Subscript = True
Else
.Subscript = False
End If
End With
End Sub