+ Reply to Thread
Results 1 to 3 of 3

How do you programically remove carriage returns within a cell

  1. #1
    Lee
    Guest

    How do you programically remove carriage returns within a cell

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

  2. #2
    ben
    Guest

    RE: 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. #3
    Dave Peterson
    Guest

    Re: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1