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.
|
Lista Forumurilor Pe Tematici
|
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login
POZE MRRRR'S FORUM (VIEW ONLY)
Nu sunteti logat.
|
Nou pe simpatie: Profil Alexanndra1994
| Femeie 23 ani Bucuresti cauta Barbat 23 - 42 ani |
|
TRaP
Moderator
Inregistrat: acum 6 ani
Postari: 787
|
|
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
Modificat de TRaP (acum 4 ani)
|
|
pus acum 4 ani |
|
TRaP
Moderator
Inregistrat: acum 6 ani
Postari: 787
|
|
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
|
|
|
pus acum 4 ani |
|