View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\) Rick Rothstein \(MVP - VB\) is offline
external usenet poster
 
Posts: 2,202
Default macro to convert string to dec

Your ultimate goal (all decimal values/only non-displaying character's
values) is not completely clear to me. The Asc function can be used to find
the ASCII/ANSI value of an individual character. The following function will
display these values (surrounded by angle brackets) for each character in
the text passed into it...

Function FindNonPrintableChars(TextIn As String) As String
Dim X As Long
For X = 1 To Len(TextIn)
FindNonPrintableChars = FindNonPrintableChars & _
"<" & Asc(Mid$(TextIn, X, 1)) & ""
Next
End Function

If you only want to see the values for the non-displaying characters, then
this function will probably do what you want...

Function FindNonPrintableChars(TextIn As String) As String
Dim X As Long
Dim Letter As String
For X = 1 To Len(TextIn)
Letter = Mid$(TextIn, X, 1)
If Asc(Letter) < 32 Then
FindNonPrintableChars = FindNonPrintableChars & _
"<" & Asc(Mid$(TextIn, X, 1)) & ""
Else
FindNonPrintableChars = FindNonPrintableChars & Letter
End If
Next
End Function


Rick


"Richard" wrote in message
...
I have cells that contain non-displaying characters, like line feeds.
How can I determine all the dec values in a cell?
Example, "abc" would be 97 98 99
That's obvious, the "abc" would just show up.
I want to also determine all the non-display characters like line feeds
and
charriage returns in a given cell.
--
Richard