vba 在 Excel 中用 Alt+Enter 替换 HTML 标记(</br>)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17874391/
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
Replace HTML tag(</br>) with Alt+Enter in Excel
提问by Lina Tum
I am working on VBA, but I have one problem of how to replace a tag of HTML with Alt+Enter. For example, If I type a sentence: Hello World. In shell of Excel, I press on Alt+Enter to Enter between Hello and World. Then I want to copy it to somewhere else that after I copied it shows like: HelloWorld. Any help would be appreciate.
我正在使用 VBA,但我遇到了一个问题,即如何用 Alt+Enter 替换 HTML 标签。例如,如果我输入一个句子:Hello World。在 Excel 的 shell 中,我按 Alt+Enter 在 Hello 和 World 之间输入。然后我想将它复制到其他地方,在我复制后显示为:HelloWorld。任何帮助将不胜感激。
回答by Cody Gray
The <br>
tag in HTML just gives you a line break.
<br>
HTML 中的标签只是给你一个换行符。
In VBA, you can accomplish the same thing using the vbNewLine
constant.
在 VBA 中,您可以使用vbNewLine
常量来完成同样的事情。
The Replace
functionwill come in handy for this.
该Replace
功能将派上用场。
Dim input As String
input = "Hello<br>World!"
Dim result As String
result = Replace$(input, "<br>", vbNewLine)
回答by LS_???
You can use Excel formula:
您可以使用 Excel 公式:
=SUBSTITUTE(B4, "<br>", "
Alt+Enter ")
=SUBSTITUTE(B4, "<br>", "
Alt+Enter ")