我如何在Excel公式中构造以下字符串:

“火箭”莫里斯·理查德

如果我使用的是单引号,那就太琐碎了:="Maurice 'The Rocket' Richard"但是双引号呢?


当前回答

我为此使用了一个函数(如果工作簿已经有VBA)。

Function Quote(inputText As String) As String
  Quote = Chr(34) & inputText & Chr(34)
End Function

这是来自Sue Mosher的书《Microsoft Outlook Programming》。那么公式是:

=“莫里斯”&quote(“火箭”)&“理查德”

这和Dave DuPlantis发布的类似。

其他回答

我为此使用了一个函数(如果工作簿已经有VBA)。

Function Quote(inputText As String) As String
  Quote = Chr(34) & inputText & Chr(34)
End Function

这是来自Sue Mosher的书《Microsoft Outlook Programming》。那么公式是:

=“莫里斯”&quote(“火箭”)&“理查德”

这和Dave DuPlantis发布的类似。

使用装备(34) 代码:

    Joe = "Hi there, " & Chr(34) & "Joe" & Chr(34)
    ActiveCell.Value = Joe

结果:

    Hi there, "joe"

这将工作的宏使用。formula = "= theformulfunction ("STUFF")" 就像这样: 这是否适用于使用。formula = "= theformulfunction (CHAR(34) & STUFF & CHAR(34))"

三个双引号:" " "x" " " = "x" Excel将自动更改为一个双引号。例如:

=CONCATENATE("""x"""," hi")  

= "x"嗨

作为一个独立的细胞连接:

    A |   B   | C | D
1   " | text  | " | =CONCATENATE(A1; B1; C1);

D1 displays "text"