vba Excel 连接引号

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

Excel concatenation quotes

excelexcel-vbavba

提问by CustomX

I'm trying to concatenate several fields and want certain fields to start and end with quotes ("....."). When I put a cell (B2) inside this, the cell (B2) is shown as plain text with quotes around it.

我正在尝试连接多个字段并希望某些字段以引号(“.....”)开头和结尾。当我在其中放置一个单元格 (B2) 时,单元格 (B2) 显示为纯文本,周围有引号。

CONCATENATE("""B2""") -> "B2"

CONCATENATE("""B2""") -> "(whatever is in cell B2)"

回答by Jook

Try this:

尝试这个:

CONCATENATE(""""; B2 ;"""")

@widor provided a nice solution alternative too - integrated with mine:

@widor 也提供了一个不错的解决方案替代方案 - 与我的集成:

CONCATENATE(char(34); B2 ;char(34))

回答by Widor

Use CHAR:

使用CHAR

=Char(34)&"This is in quotes"&Char(34)

Should evaluate to:

应评估为:

"This is in quotes"

回答by Jon Crowell

You can also use this syntax: (in column D to concatenate A, B, and C)

您还可以使用以下语法:(在 D 列中连接 A、B 和 C)

=A2 & " """ & B2 & """ " & C2

Excel formula to concatenate with quotes

用引号连接的 Excel 公式

回答by Jacq

easier answer - put the stuff in quotes in different cells and then concatenate them!

更简单的答案 - 将这些内容放在不同单元格中的引号中,然后将它们连接起来!

B1: rcrCheck.asp
C1: =D1&B1&E1
D1: "code in quotes" and "more code in quotes"  
E1: "

it comes out perfect (can't show you because I get a stupid dialog box about code)

结果很完美(无法向您展示,因为我收到了一个关于代码的愚蠢对话框)

easy peasy!!

十分简单!!

回答by UJS

I was Forming some Programming Logic Used CHAR(34)for Quotes at Excel : A small Part of same I am posting which can be helpfull ,Hopefully

我正在形成一些使用CHAR(34)进行 Excel 引用的编程逻辑:我发布的一小部分相同,希望有所帮助

1   Customers
2   Invoices

Formula Used :

使用的公式:

=CONCATENATE("listEvents.Add(",D4,",",CHAR(34),E4,CHAR(34),");")

=CONCATENATE("listEvents.Add(",D4,",",CHAR(34),E4,CHAR(34),");")

Result :

结果 :

listEvents.Add(1,"Customers");
listEvents.Add(2,"Invoices");