将公式转换为ArrayFormula

时间:2019-05-17 21:13:34

标签: google-sheets array-formulas google-sheets-formula google-sheets-query gs-vlookup

我有这个公式来计算Contents!$B$2J4中的匹配项。

=ARRAYFORMULA(IF(NOT(REGEXMATCH(J4, 
"\w")),0,SUM(COUNTIF(REGEXREPLACE(SPLIT(J4,","),"
[\s]",""),REGEXREPLACE(SPLIT(Contents!$B$2,","),"[\s]","")))))

该公式位于K4中,但理想情况下,我希望它向下工作J并将值返回到相关的相邻K。我试过了,但是没有用。刚刚填充了公式所在的单元格

=ARRAYFORMULA(IF(NOT(REGEXMATCH(J4:J, 
"\w")),0,SUM(COUNTIF(REGEXREPLACE(SPLIT(J4:J,","),"
[\s]",""),REGEXREPLACE(SPLIT(Contents!$B$2,","),"[\s]","")))))

我知道我可以填写,但是问题是用户插入行。

在此先感谢您的帮助

1 个答案:

答案 0 :(得分:1)

=ARRAYFORMULA(IF(LEN(A2:A), IFERROR(VLOOKUP(A2:A, 
 QUERY(TRIM(TRANSPOSE(SPLIT(Contents!B1, ","))), 
 "select Col1,count(Col1) group by Col1", 0), 2, 0), 0), ))

0