Results 1 to 3 of 3
  1. #1
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Removing an extra line break (Excel 2007)

    The line separator in Excel cells is ASCII character 10, which is represented by the symbolic constant vbLf. You should use ... What:=vbLf ...

    If you use What:="vbLf", Excel will look for the literal text vbLf, i.e. the letters v, b, L and f, instead of for ASCII character 10.

  2. #2
    Star Lounger
    Join Date
    Nov 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Removing an extra line break (Excel 2007)

    Thanks Hans, I knew I had to be making some sort of dummy error. That works perfectly!

  3. #3
    Star Lounger
    Join Date
    Nov 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Removing an extra line break (Excel 2007)

    I am writing some macros to reformat some Excel files and would like to remove some extra line breaks so that in a cell instead of:
    Line 1
    Line 2
    I have:
    Line 1 Line 2

    I tried removing the line breaks by using:
    <code>
    Cells.Replace What:="vbCrLf", Replacement:=" ", LookAt:=xlPart, SearchOrder _
    :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
    Cells.Replace What:="vbLf", Replacement:=" ", LookAt:=xlPart, SearchOrder _
    :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
    </code>

    But that does absolutely nothing. Anyone got any ideas on why this isn't working, or how I can do it better? My VBA only gets used every couple years and thus gets very rusty.

Posting Permissions

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