vba 将 Excel 换行符转换为 vbCrLf?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1421571/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Converting Excel line breaks to vbCrLf?
提问by Tom
My columns have line breaks, but how can I convert these to vbCrLf
when reading with Range("A" & r).Value
?
我的列有换行符,但是vbCrLf
在阅读时如何将它们转换为Range("A" & r).Value
?
回答by Daniel Rikowski
In Excel cell line breaks are represended by vbLf
, notvbCrLf
.
在 Excel 中,单元格换行符由 表示vbLf
,而不是vbCrLf
。
You can replace the line breaks manually:
您可以手动替换换行符:
Dim CellValue As String
CellValue = Replace(Range("A" & r).Value, vbLf, vbCrLf)
That replaces all Excel line breaks with standard Windows line breaks.
这将用标准的 Windows 换行符替换所有 Excel 换行符。