Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
lee lee is offline
external usenet poster
 
Posts: 184
Default How do you programically remove carriage returns within a cell

I need to do more than one cell at a time.
  #2   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default How do you programically remove carriage returns within a cell

lee type your question the body of the text please.

sub removecarret()
dim cel as range
for each cel in activesheet.usedrange
cel = replace(cel,chr(13),"")
next
end sub
UNTESTED but it should work

--
When you lose your mind, you free your life.


"Lee" wrote:

I need to do more than one cell at a time.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How do you programically remove carriage returns within a cell

Saved from a previous post to a more generic question:

You can use Chip Pearson's Cell View addin to find out the character it is:
http://www.cpearson.com/excel/CellView.htm

If those box characters are char(10)'s (alt-enters), you can use
edit|Replace
what: ctrl-j
with: (spacebar??)
replace all

If that box character is something else, you may need a macro:

Option Explicit
Sub cleanEmUp()

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

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

myGoodChars = Array(" ")

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

Lee wrote:

I need to do more than one cell at a time.


--

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
How do I remove carriage returns from a cell Belinda Excel Worksheet Functions 3 November 9th 08 07:31 AM
Remove carriage returns in an Excel document? smartnfunnyfem Excel Discussion (Misc queries) 3 August 26th 08 10:21 PM
How do I eliminate carriage returns in a cell Squirrelwatcher Charts and Charting in Excel 2 November 7th 05 03:38 PM
how do I remove Carriage Returns from a column in a spreadsheet? Doug R Excel Discussion (Misc queries) 1 June 29th 05 08:29 PM
How do I automatically remove carriage returns in Excel? Mike O. Excel Discussion (Misc queries) 4 February 18th 05 11:24 PM


All times are GMT +1. The time now is 12:39 AM.

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"