Excel VBA删除公式中的最后一个逗号?
我在Excel中有一个公式,将一整列数据串成一个大逗号分隔字符串。
我的数据看起来像下面,但我需要最后一个逗号消失,否则我会遇到语法错误。我该怎么办?
我的串联功能如下:
="'"&CONCATENATE(TRANSPOSE(L6:L43)&"',")
因此,它在做的是:
我在列中有一个零件列表:SB-12-073,SB-18-88,SB-11-001,我希望它们会串联说'SB-- 12-073','SB-18-88','SB-11-001'但SB-11-001不需要逗号。当前,连接功能正在拉开逗号。数据存储在L6和L43之间
I have a formula in EXCEL that concatenates a whole column of data into one big comma separated string.
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:
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. Currently the concatenate function is pulling the comma over. The data is stored between L6 and L43
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以像这样缠绕以摆脱最后一个字符:
Cell A1可以是您的公式。
You can wrapped around like this to get rid of the last character:
cell A1 can be your formula instead.
连接字符串的最简单方法是使用
textjoin()
工作表函数,如此示例:在此处,逗号使用一个定界线和
false
提及如何处理空的空细胞。如您所见,您无需在最后添加逗号,因此您的问题不会出现。The easiest way to concatenate string is using the
TEXTJOIN()
worksheet function, as in this example:Here, the comma is used a delimiter and
FALSE
mentions how to deal with empty cells. As you see, you don't need to add a comma at the end, so your problem won't appear.