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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 10:47:38  来源:igfitidea点击:

Converting Excel line breaks to vbCrLf?

vbaexcel-vbaexcel

提问by Tom

My columns have line breaks, but how can I convert these to vbCrLfwhen 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 换行符。