Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
|
Nou pe simpatie: Stefania23 pe Simpatie.ro
 | Femeie 24 ani Dolj cauta Barbat 25 - 46 ani |
|
|
Mrrrr's Forum (VIEW ONLY)ReguliInregistrareLoginPozeNu sunteti logat. Lista Forumurilor Pe Tematici
|
| #1 |
TRaPModerator
Postari: 960
|
|
Sub SubscriptText()
Dim cell_txt as String Dim txt As String Dim n As Long
cell_txt = ActiveCell.Value txt = InputBox("Leave only words you want to subscript / superscript", "Characters...", cell_txt) n = InStr(cell_txt, txt)
' Subscript: ACTIVATED (to deactivate, add ' before next line) ActiveCell.Characters(Start:=n, Length:=Len(txt)).Font.Subscript = True
' Superscript: DEACTIVATED (to activate, remove ' before next line) ' ActiveCell.Characters(Start:=n, Length:=Len(txt)).Font.Superscript = True End Sub
|
Source: Myself
|
|
| |
|
| #2 |
TRaPModerator
Postari: 960
|
|
So as not to have to make a UserForm, you can add the following to have both options available with InputBox choice.
If first InputBox says SUB, then text will be subscript, if SUP it will be superscript and if anything else besides the 2, subscript and superscript will both be cleared (set to False).
Sub Sub_or_SuperscriptText()
Dim strOption As String Dim cell_txt As String Dim txt As String Dim n As Long
strOption = InputBox("Leave only SUB or SUP, delete the other, leave blank to clear sub/superscript", "SUBscript / SUPERscript", "SUB SUP") If strOption <> "SUB" And strOption <> "SUP" Then ActiveCell.Characters(Start:=n, Length:=Len(txt)).Font.Subscript = False ActiveCell.Characters(Start:=n, Length:=Len(txt)).Font.Superscript = False Exit Sub End If cell_txt = ActiveCell.Value txt = InputBox("Leave only words you want to subscript/superscript", "Characters...", cell_txt) n = InStr(cell_txt, txt)
If strOption = "SUB" Then ActiveCell.Characters(Start:=n, Length:=Len(txt)).Font.Subscript = True
Else ActiveCell.Characters(Start:=n, Length:=Len(txt)).Font.Superscript = True
End If
End Sub
|
|
|
| |
|