View Full Version : vbCrLf and vbLf
mikke3141
12-27-2014, 02:25 PM
I have a huge text file that is generated by an external application. I would like to import it to excel but it contains many vbCrLf and vbLf characters. VbCrLf is a normal line break, but vbLf alone is a mistake. How can I import it to excel using vba so that the single vbLf characters would be removed and only the vbCrLf characters would remain? Thank you for your help.
Perhaps you should not crosspost:
http://www.excelforum.com/excel-programming-vba-macros/1057358-vbcrlf-and-vblf.html
Especially if you're not going to answer replies/requests in the existing threads where you have already posted the same question..
Paul_Hossler
12-28-2014, 10:06 AM
Not much information to work with, but I usually do something in 3 passes like the sample below
Option Explicit
Sub test()
Dim s As String
s = "aaaaaaaa" & vbCrLf & "bbbbbbbb" & vbLf & "ccccc"
MsgBox s
s = Replace(s, vbCrLf, Chr(1))
s = Replace(s, vbLf, vbNullString)
s = Replace(s, Chr(1), vbCrLf)
MsgBox s
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.