+ Reply to Thread
Results 1 to 20 of 20

Clearing the carriage returns in a cell with text

  1. #1
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Clearing the carriage returns in a cell with text

    Good morning!

    So I have a report that I work on every month. This report pulls data from our Oracle database. Some of the columns represent free text fields within an Oracle form. If the enter key was hit when a tech was entering data, it pulls over to this report. How can I trim or remove those extra characters without losing the text within that cell? I want to to create a code for this to incorporate within my existing formatting code. I have attached an example of this for you assistance to resolve this.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Clearing the carriage returns in a cell with text

    You can do it like this

    Please Login or Register  to view this content.
    Please take time to read the forum rules

  3. #3
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Clearing the carriage returns in a cell with text

    If inside a loop

    Please Login or Register  to view this content.

  4. #4
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Clearing the carriage returns in a cell with text

    Or, with find and replace:

    In the Find What box, hold down Alt and type 0010
    Leave the replace with field blank.

    Press replace all, will replace the carriage returns w/o a macro
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  5. #5
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Clearing the carriage returns in a cell with text

    That didn't seem to do the trick.

  6. #6
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Clearing the carriage returns in a cell with text

    General,

    I'd rather use a macro because of all the other formatting, I would like to include this with the other formatting.

  7. #7
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Clearing the carriage returns in a cell with text

    The Find-N-Replace worked with what you attached previously.

    I did notice, that if i "entered" the cell before running the Find-N-Replace, the appearance of the sheet didn't change.

    If you run it on the sheet before entering a cell (when the little box is still showing in the cell) - you can see the change. I'm assuming the change happens in either case

  8. #8
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Clearing the carriage returns in a cell with text

    General,

    I tried using the code that Steffen provided, I did not try your method. Yes, I have noticed that before and that is why I have been trying to create this code prior to me entering the cell. I tired to run the macro code before doing anything within any of the cells and yet is still does not get rid of that return.

    The report I am working on is a rather large and detailed report for the customer. The more I can do with a macro the better. So if I can remove this return within the cells with a macro during the other formatting procedures, that would be AWESOME!!!

    Any ideas?

  9. #9
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Clearing the carriage returns in a cell with text

    Try

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Clearing the carriage returns in a cell with text

    Steffen,

    That didn't work either.

  11. #11
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Clearing the carriage returns in a cell with text

    I checked the length of the entries in column B and found them to have 10 characters.

    So i did =left(B2,9) in C2.

    It removed the carriage return.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  12. #12
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Clearing the carriage returns in a cell with text

    So why doesn't that work in my code?

    these are the codes I am using...

    Please Login or Register  to view this content.
    I don't get it?!?!?!

  13. #13
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Clearing the carriage returns in a cell with text

    When this code runs, it counts the carriage return as a character and doesn't result that same as if I just enter in the formula into a cell. The code does not remove the carriage return.

  14. #14
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Clearing the carriage returns in a cell with text

    Here is an updated worksheet that I am working with. The yellow cells are the cells that have the carriage returns that will not go away.
    Attached Files Attached Files

  15. #15
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Clearing the carriage returns in a cell with text

    Add this line of code before your previous code
    Please Login or Register  to view this content.
    Also this code
    Please Login or Register  to view this content.
    can be shortened to
    Please Login or Register  to view this content.
    You can remove the trim around the ranges too.

  16. #16
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Clearing the carriage returns in a cell with text

    This is what I did with the code..

    Please Login or Register  to view this content.
    But it didn't work...ideas?

  17. #17
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Clearing the carriage returns in a cell with text

    It worked when i tried it at my end. Check post 15 on how you can shorten the code.

  18. #18
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Clearing the carriage returns in a cell with text

    if I use that short code, do I just need to place

    Please Login or Register  to view this content.
    after my declarations and before the shortened code?

  19. #19
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Clearing the carriage returns in a cell with text

    Yes you are right. I tried the replace chr(10) at my end and it worked fine.

    Updated short code
    Please Login or Register  to view this content.

  20. #20
    Forum Contributor
    Join Date
    05-13-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Clearing the carriage returns in a cell with text

    Awesome!! It works now! I have no idea what I was doing before that was causing this not to work but we are good now!!!

    THANKS!!!

+ 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