[英]Excel VBA Remove last comma in formula?
I have a formula in EXCEL that concatenates a whole column of data into one big comma separated string.我在 EXCEL 中有一个公式,它将一整列数据连接成一个逗号分隔的大字符串。
I have data that looks like the below but I need the LAST comma to disappear or else I get a syntax error.我有如下所示的数据,但我需要最后一个逗号消失,否则会出现语法错误。 What do I do?我该怎么办?
My concatenate function is the following:我的连接函数如下:
="'"&CONCATENATE(TRANSPOSE(L6:L43)&"',")
So what it's doing is EX:所以它正在做的是EX:
I have a parts list in a column: SB-12-073, SB-18-88, SB-11-001 and I want them concatenated to say 'SB-12-073', 'SB-18-88', 'SB-11-001' but the SB-11-001 needs to have NO COMMA.我在一列中有一个零件清单:SB-12-073、SB-18-88、SB-11-001,我希望它们连接起来说“SB-12-073”、“SB-18-88”、“ SB-11-001' 但 SB-11-001 需要没有逗号。 Currently the concatenate function is pulling the comma over.目前,连接功能正在将逗号拉过来。 The data is stored between L6 and L43数据存储在 L6 和 L43 之间
The easiest way to concatenate string is using the TEXTJOIN()
worksheet function, as in this example:连接字符串的最简单方法是使用TEXTJOIN()
工作表函数,如下例所示:
=TEXTJOIN(",",FALSE,A1:C1)
Here, the comma is used a delimiter and FALSE
mentions how to deal with empty cells.在这里,逗号用作分隔符, FALSE
提到了如何处理空单元格。 As you see, you don't need to add a comma at the end, so your problem won't appear.如您所见,您不需要在末尾添加逗号,因此您的问题不会出现。
You can wrapped around like this to get rid of the last character:您可以像这样缠绕以摆脱最后一个字符:
=LEFT(A1;LEN(A1)-1)
cell A1 can be your formula instead.单元格 A1 可以是您的公式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.