UDF to Convert Numbers in String to Subscript

Anonymous
2023-08-05T00:43:20+00:00

Running into challenges in developing a UDF that evaluates one string in a cell and converts all the numbers in the string to subscript.

Example string to convert: A0G2P14C0P3M6G0A0

This not working. Thanks.

Public Function NumToSub(R As Range) As String

Dim i As Integer

NumToSub = ""

With ActiveSheet.R 

    For i = 1 To .Characters.Count 

        Set ch = .Characters(i, 1) 

            If IsNumeric(ch.Text) Then 

                ch.Font.Subscript = True 

                NumToSub = NumToSub & ch.Text 

            End If 

    Next i 

End With 

End Function

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

7 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Anonymous
    2023-08-07T22:35:31+00:00

    For example: Image?

    Note: this is done with formatting, the numbers are still regular numbers.

    0 comments No comments