Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 191
Default removing char(13) with find/replace

I have found that char(10) is the equivalent of ctrl-j in the find/replace
box. Is there an equivalent way of finding char(13)?

Thanks.
--
Boris
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default removing char(13) with find/replace

I can't get anything to work manually.

So I use a macro:

Option Explicit
Sub cleanEmUp()

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

myBadChars = Array(Chr(13))

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

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

=======
If you're working with lots of those funny characters, you may want to get Chip
Pearson's addin:
http://www.cpearson.com/excel/CellView.htm

Then if you have lots of characters to fix, you can loop through them:

Option Explicit
Sub cleanEmUp()

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

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

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

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

BorisS wrote:

I have found that char(10) is the equivalent of ctrl-j in the find/replace
box. Is there an equivalent way of finding char(13)?

Thanks.
--
Boris


--

Dave Peterson
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
FIND 1 char in cell of any 3 char =True Nastech Excel Discussion (Misc queries) 5 April 26th 08 02:17 PM
How to substitute a comma with a newline char using Replace. edspyhill01 Excel Discussion (Misc queries) 9 July 30th 06 12:38 AM
Using replace box to change a character into a CR (Alt-Enter char) Excel user Excel Discussion (Misc queries) 2 June 9th 06 12:26 PM
8500 cells with phone number(7 char.), wishing to add area code (10 char.) [email protected] Excel Discussion (Misc queries) 6 March 10th 06 05:13 PM
Find if nth char = specific character.. nastech Excel Discussion (Misc queries) 6 November 24th 05 02:57 PM


All times are GMT +1. The time now is 09:44 PM.

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

About Us

"It's about Microsoft Excel"