如果列包含匹配值,则获取列名称(无需 VBA)

发布于 2025-01-09 17:23:21 字数 1539 浏览 1 评论 0原文

给定命名范围 Table1,如何从数组 Table1[#Headers] 返回该列中存在匹配输入值的所有名称?

abc
123
452
612

对于上述示例数据,我想返回

search_valueheaders
1a,b
2b,c (或 b,c,c)
3c

通过上述示例数据,我可以使用公式 =SUM(--(Table1=search_value)) 计算指定 search_value 的出现次数。鉴于该公式中现有的 True/False 数组,我一直在尝试获取相对单元格映射信息。遗憾的是

  • XMATCH 仅对一维数组
  • AGGREGATE 很有希望但到目前为止我无法评估 CELL("address",{})(或类似的),这样它返回一个可以与AGGREGATE<一起使用的数组/code>

相关工作簿是托管在 OneDrive 中的共享工作簿,因此我希望尽可能避免使用 VBA。

Given a named range Table1, how do I return all names from the array Table1[#Headers] where a matching input value exist in that column?

abc
123
452
612

For the above sample data, I would like to return

search_valueheaders
1a,b
2b,c (or b,c,c)
3c

With the above sample data, I can count the occurrences of a named search_value with the formula =SUM(--(Table1=search_value)). Given the existing True/False array from that formula, I've been trying to get relative cell mapping information. Sadly

  • XMATCH only evaluates on a 1-dimensional array
  • AGGREGATE is promising but I've so far been unable to evaluate CELL("address",{}) (or similar) such that it returns an array that I can use with AGGREGATE

The workbook in question is a shared workbook hosted in OneDrive so I'd like to avoid VBA if at all possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

堇色安年 2025-01-16 17:23:22

一种方法(使用 Office 365)是:

=FILTER(Table1[#Headers],BYCOL(--ISNUMBER(MATCH(Table1,E2,0)),LAMBDA(x,MAX(x))))

其中 E2 是搜索值。
输入图片此处描述

连接

抱歉 - 我刚刚意识到您想要连接输出:

=TEXTJOIN( ",", 1, FILTER(Table1[#Headers],BYCOL(--ISNUMBER(MATCH(Table1,E2,0)),LAMBDA(x,MAX(x)))) )

在此处输入图像描述

另一种基于 Excel for Web 的方法

这取决于支持的 SEQUENCE Excel 网页版。希望它能在 Sharepoint 上运行。如果没有,那么有一种(麻烦的)方法可以使用 ROW() 梳理出序列,但如果您不必这样做会更容易。

=TEXTJOIN(",",1,
     UNIQUE(IFERROR(INDEX(Table1[#Headers],
                    LARGE(IFERROR(MATCH(Table1,E2,0)*COLUMN(Table1[#Headers]),-1),
                          SEQUENCE(,COLUMNS(Table1),COLUMNS(Table1),-1))),
                    ""),
            1) )

One way (with Office 365) would be:

=FILTER(Table1[#Headers],BYCOL(--ISNUMBER(MATCH(Table1,E2,0)),LAMBDA(x,MAX(x))))

where E2 is search value.
enter image description here

concatenated

Sorry - I just realized that you want a concatenated output:

=TEXTJOIN( ",", 1, FILTER(Table1[#Headers],BYCOL(--ISNUMBER(MATCH(Table1,E2,0)),LAMBDA(x,MAX(x)))) )

enter image description here

Another approach based on Excel for Web

This depends on SEQUENCE which is supported in Excel for Web. Hopefully, it works on Sharepoint. If not, then there is a (cumbersome) way to tease out sequences using ROW(), but it would be easier if you don't have to go there.

=TEXTJOIN(",",1,
     UNIQUE(IFERROR(INDEX(Table1[#Headers],
                    LARGE(IFERROR(MATCH(Table1,E2,0)*COLUMN(Table1[#Headers]),-1),
                          SEQUENCE(,COLUMNS(Table1),COLUMNS(Table1),-1))),
                    ""),
            1) )
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文