Replacing alt-enter (think chr(10)) with other text

A

Andy Kessel

I'm a little out of practice and need some help.

I need a macro to replace chr(10) -( the result of using alt-enter when
editing a cell) in value cells with a string "xxxx" or whatever.

I know this is basically easy, but could use some help. I'm not sure
if I would have to navigate through all cells, and look one character
at a time and when I find this to replace it, or if there is another
way.

Certainly can't figure out how to do it with find and replace.

Thanks,

Andy Kessel
 
A

Andy Kessel

Oh never mind I found the answer. already in group. this worked great


Sub ReplaceNonPrintableCharacter()
' Use =CODE(MID(a,b,1)) to get the character
' code # of the offending character where
' a = text string
' b = character's position in string 'a'
' Ex: The above formula returns a 10 for a linefeed.
' The following replaces linefeeds with spaces.
' Replace the 10, if necessary, for your situation.


Cells.Replace _
What:=Chr(10), _
Replacement:="<br>", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top