Hi,
What would you want your example to return, can you show us?
Thanks,
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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
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.
Hi,
What would you want your example to return, can you show us?
Thanks,
Function JustNumbers(ByVal What As String) As String
'Return only numbers from What (by Rick Rothstein)
Dim i As Long, j As Long, Digit As String
For i = 1 To Len(What)
Digit = Mid$(What, i, 1)
If Digit Like "#" Then
j = j + 1
Mid$(What, j, 1) = Digit
End If
Next
JustNumbers = Left$(What, j)
End Function
【批量数字下标-batch number subscript-哔哩哔哩】 How about this way?
I'm sorry but your post is not helpful in this forum.
The reason for this is the language, all participants here speak English or can use a translator to translate English text into their language.
Your native language is probably Chinese, so nobody will probably understand your video. Me neither, because the OP asked for a VBA solution, not how to do anything with copy and paste.
Please keep in mind that your solutions here are only helpful if they are written in English. Nobody can read what is written in Chinese to the left and right of "batch number subscript" above.
There are also forums in your language, it might make more sense to get more involved in these forums.
https://answers.microsoft.com/zh-hans/msoffice/forum/msoffice_excel
https://answers.microsoft.com/zh-hant/msoffice/forum/msoffice_excel
Andreas.
Sorry I have deleted Chinsese.
I am here just for fun.
If not helpful,please delete it.