The code below converts a string to chemical formula (subscript numeric characters). If I want to change the subscript characters to a markup character ("_") what should I do? For example CH2CH2CH3 to CH_2CH_2CH_3, or C6H11 to C_6H_1_1
Code:
Sub test()
For x = 1 To Len(ActiveCell)
char = Mid(ActiveCell, x, 1)
If Asc(char) >= 48 And Asc(char) <= 57 Then ActiveCell.Characters(Start:=x, Length:=1).Font.Subscript = True
Next x
End Sub