You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Excel中查询特定测试人员对应的所有widget_id列表?

解决方案

方法1:Excel 365/2021 动态数组公式

假设查询邮箱放在单元格G1(例如jack@company.com),在目标单元格输入以下公式:

=TEXTJOIN(", ", TRUE, FILTER(allocations!A:A, (allocations!B:B=G1)+(allocations!E:E=G1), "无匹配部件"))
  • 逻辑说明:
    • FILTER函数筛选allocations表的widget_id列(A列),条件是B列或E列等于查询邮箱(+代表逻辑或),无匹配时返回「无匹配部件」。
    • TEXTJOIN把筛选出的ID用逗号加空格拼接成字符串,TRUE参数会自动忽略空值。

方法2:旧版Excel(无动态数组支持)

如果你的Excel版本不支持动态数组,用以下数组公式(输入后按Ctrl+Shift+Enter确认生效):

=TEXTJOIN(", ", TRUE, IF((allocations!$B:$B=G1)+(allocations!$E:$E=G1), allocations!$A:$A, ""))

若旧版无TEXTJOIN函数:

可以自定义VBA函数实现:

  1. 按Alt+F11打开VBA编辑器。
  2. 插入新模块,粘贴以下代码:
Function GetWidgets(email As String) As String
    Dim ws As Worksheet
    Dim lastRow As Long
    Dim i As Long
    Dim result As String
    
    Set ws = ThisWorkbook.Worksheets("allocations")
    lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
    
    For i = 2 To lastRow '假设第1行是表头
        If ws.Cells(i, "B").Value = email Or ws.Cells(i, "E").Value = email Then
            If result = "" Then
                result = ws.Cells(i, "A").Value
            Else
                result = result & ", " & ws.Cells(i, "A").Value
            End If
        End If
    Next i
    
    GetWidgets = result
End Function
  1. 返回工作表,在单元格输入=GetWidgets(G1)即可得到目标列表。

内容的提问来源于stack exchange,提问作者Kris

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 06:13:32