0
votes

I'm writing VBA codes to read spreadsheet contents and write to a TXT file.

Some of the cells has multi-line text. They are displayed as multi-line in the spreadsheet.

However, when the VBA code read the cell and write to the TXT file, they appear on the same line. This also happens when I copy the cell and past it into Notepad.

For example in spreadsheet, cell A1 appears as:

Text1
Text2
Text3

But in TXT file, it appears as: Text1Text2Text3.

So I guess CHAR(10) in Excel is not equivalent to vbNewLine in VBA? What do I need to do to get the line breaks into TXT file? Thank you!

2
Try char(13) & char(10) instead of only char(10).zedfoxus
Please post the code you use to generate the text file with.Miqi180

2 Answers

0
votes

Do a Replace(YourCellValue, vbLf, vbCrLf) to get line breaks that works in Windows.

0
votes

I had the same problem, and resolved it by changing my column to word wrap. Please be gentle if this is a silly solution - this is my first answer on the forum. :-)