Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
HappyCamper
 
Posts: n/a
Default Replacing ascii characters

I have imported information from Access where one of the fields contains
manual line breaks. It appears Excel converts the manual line break into a
square box. I would like to do a find and replace on these square boxes but
am having a hard time figuring out what code to use. I am thinking the ascii
code is either 10 or 13 for the mlb. So for the find field what would you
type? I have tried CHAR(10) and CHAR(13) but when it searches it says it
can't find the data I am searching for. I know I was able to accomplish this
a year or so ago but have since forgotten how to do it. Anyone have a
suggestion?

In general, if you are searching for symbols within an Excel file, how do
you indicate the ascii code in the "find what" field?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Replacing ascii characters

Chip Pearson has a very nice addin that will help determine what that
character(s) is:
http://www.cpearson.com/excel/CellView.htm

Since you do see a box, then you can either fix it via a helper cell or a macro:

=substitute(a1,char(13),"")
or
=substitute(a1,char(13)," ")

Replace 13 with the ASCII value you see in Chip's addin.

Or you could use a macro (after using Chip's CellView addin):

Option Explicit
Sub cleanEmUp()

Dim myBadChars As Variant
Dim myGoodChars As Variant
Dim iCtr As Long

myBadChars = Array(Chr(9), Chr(160)) '<--What showed up in CellView?

myGoodChars = Array(" "," ") '<--what's the new character?

If UBound(myGoodChars) < UBound(myBadChars) Then
MsgBox "Design error!"
Exit Sub
End If

For iCtr = LBound(myBadChars) To UBound(myBadChars)
ActiveSheet.Cells.Replace What:=myBadChars(iCtr), _
Replacement:=myGoodChars(iCtr), _
LookAt:=xlPart, SearchOrder:=xlByRows, _
MatchCase:=False
Next iCtr

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

-------
Sometimes those funny characters don't work in the edit|Find dialog. alt-0010
(alt-enters) work ok. char(13) have never worked for me.

HappyCamper wrote:

I have imported information from Access where one of the fields contains
manual line breaks. It appears Excel converts the manual line break into a
square box. I would like to do a find and replace on these square boxes but
am having a hard time figuring out what code to use. I am thinking the ascii
code is either 10 or 13 for the mlb. So for the find field what would you
type? I have tried CHAR(10) and CHAR(13) but when it searches it says it
can't find the data I am searching for. I know I was able to accomplish this
a year or so ago but have since forgotten how to do it. Anyone have a
suggestion?

In general, if you are searching for symbols within an Excel file, how do
you indicate the ascii code in the "find what" field?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bernie Deitrick
 
Posts: n/a
Default Replacing ascii characters

HappyC,

Select the cells, then try this little macro, which will replace characters 10 and
13 with spaces.

HTH,
Bernie
MS Excel MVP


Sub ReplaceReturns()
Selection.Replace Chr(10), " ", xlPart
Selection.Replace Chr(13), " ", xlPart
End Sub





"HappyCamper" wrote in message
...
I have imported information from Access where one of the fields contains
manual line breaks. It appears Excel converts the manual line break into a
square box. I would like to do a find and replace on these square boxes but
am having a hard time figuring out what code to use. I am thinking the ascii
code is either 10 or 13 for the mlb. So for the find field what would you
type? I have tried CHAR(10) and CHAR(13) but when it searches it says it
can't find the data I am searching for. I know I was able to accomplish this
a year or so ago but have since forgotten how to do it. Anyone have a
suggestion?

In general, if you are searching for symbols within an Excel file, how do
you indicate the ascii code in the "find what" field?



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
Formula to replace invalid filename characters tschultz Excel Worksheet Functions 2 January 27th 06 07:07 PM
Replacing specific characters Trey Excel Discussion (Misc queries) 3 January 20th 06 11:57 PM
Help - Can't directly input Japanese characters into cell NKK Excel Discussion (Misc queries) 0 January 3rd 06 02:00 AM
Replacing specific characters with spaces Night Owl Excel Worksheet Functions 3 May 13th 05 05:52 PM
Replacing characters OhhAhh Excel Worksheet Functions 10 March 4th 05 12:28 AM


All times are GMT +1. The time now is 05:53 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"