本文翻译自:How to create strings containing double quotes in Excel formulas?
How can I construct the following string in an Excel formula: 如何在Excel公式中构造以下字符串:
Maurice "The Rocket" Richard 莫里斯·“火箭”理查德
If I'm using single quotes, it's trivial = "Maurice 'The Rocket' Richard"
but what about double quotes? 如果我使用单引号,那么它就很简单= "Maurice 'The Rocket' Richard"
但是双引号又如何呢?
#1楼
参考:https://stackoom.com/question/uLo/如何在Excel公式中创建包含双引号的字符串
#2楼
I use a function for this (if the workbook already has VBA). 为此,我使用了一个功能(如果工作簿已经具有VBA)。
Function Quote(inputText As String) As String
Quote = Chr(34) & inputText & Chr(34)
End Function
This is from Sue Mosher's book "Microsoft Outlook Programming". 这来自Sue Mosher的书“ Microsoft Outlook编程”。 Then your formula would be: 那么您的公式将是:
="Maurice "&Quote("Rocket")&" Richard"
This is similar to what Dave DuPlantis posted. 这类似于Dave DuPlantis发布的内容。
#3楼
Three double quotes: " " " x " " "
= "x"
Excel will auto change to one double quote. 三个双引号: " " " x " " "
= "x"
Excel将自动更改为一个双引号。 eg: 例如:
=CONCATENATE("""x"""," hi")
= "x" hi =“ x”嗨
#4楼
VBA Function VBA功能
1) .Formula = "=""THEFORMULAFUNCTION ""&(CHAR(34) & ""STUFF"" & CHAR(34))" 1).Formula =“ =”“ THEFORMULAFUNCTION”“&(CHAR(34)&”“ STUFF”“&CHAR(34))”
2) .Formula = "THEFORMULAFUNCTION ""STUFF""" 2).Formula =“ THEFORMULAFUNCTION”“ STUFF”“”“
The first method uses vba to write a formula in a cell which results in the calculated value: 第一种方法使用vba在单元格中写入公式,该公式将得出计算值:
THEFORMULAFUNCTION "STUFF"
The second method uses vba to write a string in a cell which results in the value: 第二种方法使用vba在单元格中写入一个字符串,该字符串产生以下值:
THEFORMULAFUNCTION "STUFF"
Excel Result/Formula Excel结果/公式
1) ="THEFORMULAFUNCTION "&(CHAR(34) & "STUFF" & CHAR(34)) 1)=“ THEFORMULAFUNCTION”&(CHAR(34)&“ STUFF”&CHAR(34))
2) THEFORMULAFUNCTION "STUFF" 2)形式功能“填充”
#5楼
您是否尝试过使用双引号进行转义?
= "Maurice ""The Rocket"" Richard"
#6楼
另外,您可以使用CHAR
函数:
= "Maurice " & CHAR(34) & "Rocket" & CHAR(34) & " Richard"