+ Reply to Thread
Results 1 to 7 of 7

Forcing a line feed within a cell (Carriage Return)

Hybrid View

  1. #1
    Registered User
    Join Date
    08-27-2007
    Location
    San Antonio Texas
    Posts
    41

    Forcing a line feed within a cell (Carriage Return)

    good morning - I've got a spreadsheet that I'm interested in applying a find a replace function to. I'm not even sure Excel does this (let alone VBE), but I thought I'd ask anyway. The information below is an example of what I have throughout one column:

    ZINC INFO:\n2-1 3/4'SL\n2-MTTB\n2-DD\n2-MRB\n\nProp Size: 26L/R26 (3 Blades)\nOTHER:

    The program that I'm loading the data from inserts "\n" for a line feed, and I'd like to be able to find and replace the "\n" with a line feed (within the cell) when it finds "\n". Does anyone know of a way to do that?

    Thanks in advance, and happy Monday!

    Marcus

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon Marcus Gee

    I'm not even sure Excel does this
    Sure does. Just press Alt + Enter.

    let alone VBE
    Does this too. Not sure which one you're after, but here goes :
    Sub test()
    Range("A1").Value = "happy" & vbLf & "birthday"
    End Sub
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    A few ways

    vbCr
    vbCrLf
    vbLf
    vbNewLine
    Chr(10)
    Chr(13)
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Afternoon Noob

    Quote Originally Posted by VBA Noob
    vbCr
    vbCrLf
    vbLf
    vbNewLine
    Chr(10)
    Chr(13)
    Only vbLf and Chr(10) are suitable for use in a worksheet cell - all the rest add "invisible" line feed characters. Oddly enough, they don't appear when used to force a new line in a MsgBox.

    DominicB

  5. #5
    Registered User
    Join Date
    08-27-2007
    Location
    San Antonio Texas
    Posts
    41

    Excellent!

    You guys are awesome. I've printed out the variety of ways and I'll give them each a try tomorrow. By the way, most of you helped with the scheduling macro in one way or another, so I wanted to let you know that we implemented over the past couple of days and they are blown away - works like a champ. Is there another forum or place that I can post macros to for others to use? There's really nothing propietary about the macro itself, and I thought it might be a good thing to share.

    Thanks again - Marcus

  6. #6
    Registered User
    Join Date
    01-02-2013
    Location
    Arganda, Madrid, Spain
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Excellent!

    Line feed and carriage return are codes 10 13, sorry, not eleven, but are still not working on an excel sheet, not using VBA, some examples:
    =CONCATENATE(B4;CHAR(10);CHAR(13);I4) = same as if you don't write the char sentences
    =CONCATENATE(B7;vbNewLine;I7) = cell shows #name?
    =B8&CHAR(10)&CHAR(13)&I8 = same as if you don't include any thing related with char$

    Resuming, nothing works

    in other situations i was used something like that:

    =IF(A116="";"";HYPERLINK("mailto:"&VLOOKUP(A116;Dirs!A:C;3;FALSE)&" ?subject=something%20to_write"&"&body="&VLOOKUP(VLOOKUP(A116;Dirs!A:H;8;FALSE);Textos!A:G;2;FALSE)&VLOOKUP(A116;Dirs!A:E;4;FALSE)&VLOOKUP(VLOOKUP(A116;Dirs!A:H;8;FALSE);Textos!A:G;3;FALSE)&D116&VLOOKUP(VLOOKUP(A116;Dirs!A:H;8;FALSE);Textos!A:G;4;FALSE)&"%0a%0d"&VLOOKUP(VLOOKUP(A116;Dirs!A:H;8;FALSE);Textos!A:G;5;FALSE)&"%0a%0d"&"Someone responsible";VLOOKUP(A116;Dirs!A:E;2;FALSE)))

    note the use of &"%0a%0d"& but in this momment cell is creating HTML, in no other ocasions i have LF&CR working inside a cell.

    Does anyone have something new?

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Do a Find/Replace

    Find What: \n

    Replace With: hold down Alt key and type 013 with the Numpad on the right of the keyboard. 011 is for carriage return
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

+ 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