Create Superscript and Subscript Macros

Published: 14 December 2021
on channel: Dinesh Kumar Takyar
2,526
51

How to create Superscript and Subscript Macros to format Excel worksheet data.
Here's the complete VBA code:
Option Explicit
Dim intBegin As Integer
Dim intLen As Integer


Private Sub cmdClearData_Click()
TextBox1.Text = ""
End Sub

Private Sub cmdGetDataFromSheet_Click()
TextBox1.Text = ActiveCell.Text
End Sub

Private Sub cmdNormal_Click()
intLen = TextBox1.SelLength

If intLen Greater Than 0 Then
intBegin = TextBox1.SelStart + 1
ActiveCell.Characters(intBegin, intLen).Font.Subscript = False
ActiveCell.Characters(intBegin, intLen).Font.Superscript = False
End If
End Sub

Private Sub cmdSubScript_Click()
intLen = TextBox1.SelLength

If intLen Greater Than 0 Then
intBegin = TextBox1.SelStart + 1
ActiveCell.Characters(intBegin, intLen).Font.Subscript = True
End If

End Sub

Private Sub cmdSuperScript_Click()
intLen = TextBox1.SelLength

If intLen Greater Than 0 Then
intBegin = TextBox1.SelStart + 1
ActiveCell.Characters(intBegin, intLen).Font.Superscript = True
'ActiveCell.Characters(intBegin, intLen).Font.Superscript = True

End If

End Sub

Private Sub cmdUnload_Click()
Unload UserForm1
End Sub

NOTE: Please replace 'Greater Than' with angular bracket.
Get more details here: https://www.exceltrainingvideos.com/c...


On this page of the site you can watch the video online Create Superscript and Subscript Macros with a duration of hours minute second in good quality, which was uploaded by the user Dinesh Kumar Takyar 14 December 2021, share the link with friends and acquaintances, this video has already been watched 2,526 times on youtube and it was liked by 51 viewers. Enjoy your viewing!