Excel VBA删除公式中的最后一个逗号?

发布于 2025-02-08 12:46:00 字数 334 浏览 2 评论 0原文

我在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谁与争疯 2025-02-15 12:46:01

您可以像这样缠绕以摆脱最后一个字符:

=LEFT(A1;LEN(A1)-1)

Cell A1可以是您的公式。

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.

提笔落墨 2025-02-15 12:46:00

连接字符串的最简单方法是使用textjoin()工作表函数,如此示例:

=TEXTJOIN(",",FALSE,A1:C1)

在此处,逗号使用一个定界线和false提及如何处理空的空细胞。如您所见,您无需在最后添加逗号,因此您的问题不会出现。

The easiest way to concatenate string is using the TEXTJOIN() worksheet function, as in this example:

=TEXTJOIN(",",FALSE,A1:C1)

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文