excel vba char(10) in 每个函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44126456/
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-12 12:37:23  来源:igfitidea点击:

excel vba char(10) in for each function

excelvbaexcel-vba

提问by Manish

I am getting error "function not defined" for following code. Can anyone look into this and give me a solution. My thanks in advance!

以下代码出现错误“未定义函数”。任何人都可以调查这个并给我一个解决方案。我提前致谢!

Dim X As String,cell as Range
For Each Cell in Range("A1:A4")
  If(Len(cell.value)>0) Then
  X=X & CHAR(10) & Cell.Value
End If
Next
Range("B1").Value= X

Range("B1").WrapText = True
Range("B1").Columns.AutoFit

Here I want to concatenate each non-blank cell into each line in single cell and wrap the text.

在这里,我想将每个非空白单元格连接到单个单元格中的每一行并包装文本。

回答by Romcel Geluz

line X=X & CHAR(10) & Cell.Valueshould be X=X & CHR(10) & Cell.Value

线X=X & CHAR(10) & Cell.Value应该是 X=X & CHR(10) & Cell.Value