如何在Excel公式中创建包含双引号的字符串?

本文探讨了如何在Excel公式中构造包含双引号的字符串。通过使用单引号作为转义字符,或者利用VBA函数等方式,可以成功创建如'Maurice "The Rocket" Richard'这样的字符串。在Excel中,连续输入三个双引号会被自动转换为一个双引号。帖子还提供了具体的公式和VBA代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文翻译自: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"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值