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

如何在Google Sheets中用ArrayFormula实现Query批量自动搜索?

问题:Google表格用ArrayFormula+Query实现逐行搜索自动化

我有一个Google表格,需要用Query函数逐行获取对应搜索数据,希望通过ArrayFormula实现该搜索流程的自动化。

预期结果

检查短语结果1结果2结果3结果4
AppleAppleIce AppleCustard apple/Sugar apple/SweetsopRose apple/Water apple
berryCape gooseberry/Inca berry/Physalis
manMangoMangosteen
mom
fruitDragon fruitEgg fruitPassion fruitBlack sapote/Chocolate pudding fruit
jJackfruitJujubeJenipapo
nakeSnake fruit/Salak
meHorned MelonHoneydew melonMedlar fruitMouse melon

当前情况

检查短语结果1结果2结果3结果4
AppleAppleIce Apple
berryAppleIce Apple
manAppleIce Apple
momAppleIce Apple
fruitAppleIce Apple
jAppleIce Apple
nakeAppleIce Apple
meAppleIce Apple

现有单行公式

=IF(LEN(F2:F)=0, IFERROR(1/0), IF(LEN(F2:F)>0, Query(TRANSPOSE(QUERY(Fruits!B:B, "select B where B contains '" & F2:F & "'")),"select * limit 12")))

解决方案

替换成以下公式,放在结果1列的起始单元格(比如G2)即可实现自动化逐行搜索:
=ArrayFormula(BYROW(F2:F, LAMBDA(x, IF(LEN(x)=0,, TRANSPOSE(QUERY(Fruits!B:B, "select B where B contains '"&x&"' limit 12"))))))

说明

  • 用BYROW遍历F列的每一个检查短语,LAMBDA(x)将当前行的短语赋值给变量x
  • 对每个x执行Query搜索,通过TRANSPOSE把纵向的搜索结果转成横向,自动填充到后续的结果列
  • 空的检查短语会返回空值,避免错误内容填充

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.11 16:45:31