我有一个名为" Notes(原子量)"其中包含任意(0到n)个搜索键。
和一个名为" NOTES"
的相应命名范围如何进行vlookup / Query或Filter,以便得到名为&#34的组合列;注意文本" (见下图)?
如果Notes列中只有一个搜索键,我可以使用
IF(LEN(W3)>0, VLOOKUP(W3, NOTES, 2, false) , )
但现在我在一列中有任意数量的搜索键。如何在不分割和创建更多单元格的情况下进行处理,然后将它们全部拼接回来(添加更多列非常混乱,因为我表中的许多其他列也需要相同的修复)。
答案 0 :(得分:2)
试试这个公式:
=TRANSPOSE(SPLIT(JOIN(char(10),ArrayFormula(IFERROR(VLOOKUP("["&SPLIT(JOIN("! ",A1:A4),"![",1),D1:E3,2,0),"!"))),char(10)&"!"&char(10),0))
示例文件:
答案 1 :(得分:1)
Max&#39的解决方案非常棒!花了我一个多小时来分析并最终了解公式。
根据我的需要,我没有组合行并执行单个评估。相反,我使用以下简化公式重复了每一行的公式(这解决了当空行时的对齐错误)
= JOIN(char(10), ArrayFormula(
IFERROR(
VLOOKUP("["&SPLIT( A10 ,"[]", TRUE) &"]",NOTES,2,0),
"Error")
)
)
以下是对Max公式的每个部分的含义的细分。 从内部(1)开始调试到外部(7)
//(7) Finally, we TRANSPOSE the Columns into Rows
TRANSPOSE(
//(6) Now, we SPLIT the column up with the delimiter “\n!\n”
// that was added during Step (1)
SPLIT(
//(5) we now JOIN back all the columns, adding a new line “char(10)" before every column
JOIN(
char(10) //prepend with new line
//(4) The Magic !! ARRAYFORMULA enables the display of values returned from an array formula into multiple rows and/or columns
// Result is now displayed across multiple columns
,ArrayFormula(
IFERROR(
//(3) We can now do a VLOOKUP for each of the split search key
// (but only The first result is displayed)
VLOOKUP(
“[“ //reinsert the [ back after the split
//(2) Now, SPLIT up everything using delimiter “!”(new Row) And “[“ (new item)
& SPLIT(
//******** START FROM HERE*********
//(1) - take all the rows of interest, and then
// JOIN them together with a “!<SPACE>”
JOIN(
"! " //delimiter !<SPACE> ?
,A1:A4) //text to join (all the rows of interests)
,"![“
,TRUE) // split by each
,NOTES //Named range of interest
,2 //take second second column
,FALSE)
,”!”) // insert ! If error
) //ArrayFormula
) //JOIN
,char(10)&"!"&char(10) //delimiter "\n!\n” for split
,FALSE // do not split by each
) //SPLIT
) // TRANSPOSE