How to find and replace numbers with subscript in Excel?
Find and replace all numbers with subscript by VBA
Find and replace numbers with subscript in chemical formulas by Kutools for Excel
Subscript numbers in Chemical Formulas (subscript all numbers after each element in chemical formulas.)
Recommended Excel Productivity Tools
In Excel, except to macro code, there is no method can help you find and replace text with subscript format.
1. Press Alt + F11 key to display Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste below code to the blank script.
VBA: Find and replace all numbers with subscript format
Sub SubscriptNumbers() 'UpdatebyExtendoffice20160705 Dim xRg As Range Dim xTxt As String Dim xCell As Range Dim xChar As String Dim I As Long On Error Resume Next If ActiveWindow.RangeSelection.Count > 1 Then xTxt = ActiveWindow.RangeSelection.AddressLocal Else xTxt = ActiveSheet.UsedRange.AddressLocal End If Set xRg = Application.InputBox("Select a range:", "Kutools for Excel", xTxt, , , , , 8) If xRg Is Nothing Then Exit Sub Application.ScreenUpdating = False For Each xCell In xRg xTxt = xCell.Value For I = 1 To Len(xTxt) xChar = Mid(xTxt, I, 1) If xChar >= "0" And xChar <= "9" Then xCell.Characters(I, 1).Font.Subscript = True End If Next Next Application.ScreenUpdating = True End Sub
3. Press F5 key, a Kutools for Excel dialog pops out to remind you select a working range. See screenshot:
4. After selecting, click OK, and the all numbers in the selection have been converted to be subscript.
In additional to macro code, actually, you can apply an easy utility called Subscript numbers in Chemical Formulas to quickly convert all normal numbers in chemical formulas to subscript format if you have installed Kutools for Excel.
|Kutools for Excel, with more than 120 handy Excel functions, enhance your working efficiency and save your working time.|
After free installing Kutools for Excel, please do as below:
Select the cells you want to format the numbers as subscript, click Kutools > Text > Subscript numbers in Chemical Formulas. See screenshot:
And a dialog pops out to remind you how many cells have been converted, and the numbers in selected chemical formulas have been formatted as subscript format.
|Kutools for Excel: 300 + functions you must have in Excel, 60-day free trial from here|