+ Reply to Thread
Results 1 to 27 of 27

How can I add a carriage return to VBA code

  1. #1
    Registered User
    Join Date
    03-22-2015
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    42

    How can I add a carriage return to VBA code

    I have the below code for my Excel spreadsheet

    Please Login or Register  to view this content.


    I'm seeking assistance to find out how I can insert a carriage return in the output.

    Any help would be greatly appreciated.

    Thanks!
    Last edited by tbrookes3; 06-28-2017 at 10:51 PM.

  2. #2
    Forum Contributor
    Join Date
    06-17-2012
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    150

    Re: How can I add a carriage return to VBA code

    Type ' & vbCrLf ' at the end of every line

  3. #3
    Registered User
    Join Date
    03-22-2015
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: How can I add a carriage return to VBA code

    Sorry for a silly question but I don't know much about VBA. Do you mean literally every line - like this??


    Please Login or Register  to view this content.
    Last edited by tbrookes3; 06-28-2017 at 10:51 PM. Reason: Fixed code tags as per Rule 3

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How can I add a carriage return to VBA code

    Try change to

    Please Login or Register  to view this content.
    Last edited by jindon; 06-28-2017 at 11:09 PM.

  5. #5
    Registered User
    Join Date
    03-22-2015
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: How can I add a carriage return to VBA code

    Sincere apologies for incorrect tagging of code. I'm very new to this. Hopefully, I have done it right.

  6. #6
    Registered User
    Join Date
    03-22-2015
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: How can I add a carriage return to VBA code

    Thankyou for your help. I'm now realising that because of the amount of text; that I need to have a carriage return and a blank line between each output. Is this possible?

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How can I add a carriage return to VBA code

    I'm out for about 2.3 hrs.
    If you upload a wokbook with your desired results. it may help.

  8. #8
    Registered User
    Join Date
    03-22-2015
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: How can I add a carriage return to VBA code

    Hello

    Please find attached an example workbook. I am using the following macro:

    Please Login or Register  to view this content.
    Thanks for all your help
    Last edited by tbrookes3; 06-29-2017 at 02:16 AM. Reason: added workbook

  9. #9
    Registered User
    Join Date
    03-22-2015
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: How can I add a carriage return to VBA code

    Workbook attached this time!
    Last edited by tbrookes3; 07-02-2017 at 11:02 AM.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How can I add a carriage return to VBA code

    And how do you want it?
    I need to see your desired result.

  11. #11
    Registered User
    Join Date
    03-22-2015
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: How can I add a carriage return to VBA code

    At the moment, with the current vba coding, it looks like it does in the attached Example2 Column BB, but I want it to look like it does in Column BC. Hope that makes sense?
    Last edited by tbrookes3; 07-02-2017 at 11:03 AM.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How can I add a carriage return to VBA code

    Just change to
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    03-22-2015
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: How can I add a carriage return to VBA code

    Thankyou!! This should work perfectly.

  14. #14
    Registered User
    Join Date
    03-22-2015
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: How can I add a carriage return to VBA code

    It worked perfectly in my example spreadsheet but when I tried it in my real spreadsheet I got a what is a run-time error '13': Type mismatch

    Could it be because my spreadsheet is too big? It has 11,000 rows.

    Thankyou for all your help so far.

  15. #15
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: How can I add a carriage return to VBA code

    Hello
    Copy your original file and open it then delete all the rows except 20 for example to make it lighter and easier to upload .. and upload it
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How can I add a carriage return to VBA code

    Possibly you have Error value somewhere or join text exceed the limit.

  17. #17
    Registered User
    Join Date
    03-22-2015
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: How can I add a carriage return to VBA code

    Hello, I've done this and will upload the file in a minute. When I delete all the rows except the first 20, it works fine. Could it be because there are so many rows? 11,000 in my original spreadsheet?

  18. #18
    Registered User
    Join Date
    03-22-2015
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: How can I add a carriage return to VBA code

    Is there a way to find out what the join text exceed limit is? This might be my problem.

  19. #19
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How can I add a carriage return to VBA code

    No, deleting rows mean nothing.
    Unless I see the data, I can't do anything.

  20. #20
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How can I add a carriage return to VBA code

    Can you just upload a workbook with 2 columns only ?

  21. #21
    Registered User
    Join Date
    03-22-2015
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: How can I add a carriage return to VBA code

    Sure, let me try that... just give me a few minutes

  22. #22
    Registered User
    Join Date
    03-22-2015
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: How can I add a carriage return to VBA code

    Sure, let me try that... just give me a few minutes
    Attached Files Attached Files
    Last edited by tbrookes3; 07-02-2017 at 11:09 AM. Reason: added workbook

  23. #23
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How can I add a carriage return to VBA code

    OOps, sorry I need to see 3 columns like your original thread.

    https://www.excelforum.com/excel-pro...e-records.html

  24. #24
    Registered User
    Join Date
    03-22-2015
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: How can I add a carriage return to VBA code

    OK, here's my updated spreadsheet. Hope this makes sense.
    Attached Files Attached Files

  25. #25
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How can I add a carriage return to VBA code

    You have more than 10000 length of concatenated character in some cell, so it will be the problem.

    Displaying to the immediate window is no problem but in the range... I got no response.
    Please Login or Register  to view this content.

  26. #26
    Registered User
    Join Date
    03-22-2015
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: How can I add a carriage return to VBA code

    Hello, is there any way to change the code so that it says something like "More..." where the text exceeds 10000 characters?

  27. #27
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How can I add a carriage return to VBA code

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] replacing two carriage return wit one carriage return
    By CDandVinyl in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-05-2015, 05:55 PM
  2. Carriage Return
    By hezcal1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-23-2012, 09:27 AM
  3. Add Carriage Return to Header Using VBA
    By PY_ in forum Excel General
    Replies: 1
    Last Post: 10-19-2011, 01:13 PM
  4. Tab Carriage Return
    By WhtKnt in forum Excel General
    Replies: 5
    Last Post: 01-05-2011, 05:00 PM
  5. Carriage Return in cell
    By g48dd in forum Excel General
    Replies: 3
    Last Post: 12-28-2007, 02:24 AM
  6. Carriage Return
    By rexmann in forum Excel General
    Replies: 3
    Last Post: 05-09-2006, 11:25 AM
  7. Squares for carriage return
    By Helena in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM

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