Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default macro to convert string to dec

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default macro to convert string to dec

Thanks Rick,
I was able to find this function on the web,and it worked fine for me

Dim i As Long
Dim x() As Byte
x = StrConv(Range("a3").Value, vbFromUnicode) ' Convert string.
For i = 0 To UBound(x)
Debug.Print x(i)
Next
--
Richard


"Rick Rothstein (MVP - VB)" wrote:

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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default macro to convert string to dec

Yes, a Byte array solution will also work (assuming you want all characters
to be converted to their ASCII/ANSI decimal values).

Rick


"Richard" wrote in message
...
Thanks Rick,
I was able to find this function on the web,and it worked fine for me

Dim i As Long
Dim x() As Byte
x = StrConv(Range("a3").Value, vbFromUnicode) ' Convert string.
For i = 0 To UBound(x)
Debug.Print x(i)
Next
--
Richard


"Rick Rothstein (MVP - VB)" wrote:

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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro - Insert Equal Sign to Convert String to Formula Access''03_NewUser Excel Discussion (Misc queries) 3 October 18th 12 05:33 PM
Convert to string help pokdbz Excel Discussion (Misc queries) 1 June 10th 08 04:59 PM
Convert string Excel ESG Excel Programming 16 June 5th 07 04:09 PM
macro to convert text string Ken Wright Excel Programming 1 September 2nd 03 08:49 PM
macro to convert text string Tom Ogilvy Excel Programming 0 August 29th 03 04:38 PM


All times are GMT +1. The time now is 09:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"