Google sheets - VLOOKUP inside ARRAYFORMULA

这一生的挚爱 提交于 2019-12-13 03:24:24

问题


I am trying to do Vlookup inside an Array formula in Google Sheets.

I have two sheets, S1 and S2.

Each has 3 identical columns, Col A (Date), Col B(Name) and Col C(Payment-Type)

I would like to read the payment type from sheet 2 into sheet 1 based upon date and name combination match. Meaning if the date and name matches in sheet 2, return the Payment Type.

Here is my Vlookup formula,

=VLOOKUP(A2,FILTER('S2'!A2:C7,'S2'!A2:A7 = A2,'S2'!B2:B7 = B2),3,FALSE)

Above formula explained:

S1 is sheet 1 and S2 is sheet 2

A2 <- Date from sheet 1

'S2'!A2:C7 <- Entire sheet 2 range

'S2'!A2:A7 = A2 <- Comparing sheet 2 dates with Date in A2 of sheet 1

'S2'!B2:B7 = B2 <- Comparing sheet 2 names with Name in B2 of sheet 1

3 <- Returning the third column value which is Payment Type if the date and name match.

This works well. Here is a link to the spreadsheet with an example:

https://docs.google.com/spreadsheets/d/1tIlq_kBWlM1Stj_Iqoua2LswW2IUl7TBbhnFFhPX4uo/edit?usp=sharing

I would like to replace the Vlookup formulas on all rows with just one Array formula in the second row.

This is what I have now which is not working.

=ARRAYFORMULA(VLOOKUP($A$2:$A$7,FILTER('S2'!A$2:C$7,'S2'!$A$2:A7 = $A$2:$A$7,'S2'!$B$2:B7 = $B$2:B7),3,FALSE))

Please, can someone tell me what is wrong here? I am pretty poor with these formulas. Kindly refer the sheet I attached above. That will explain everything to you.


回答1:


Remove all contents of column C and then enter in C1

={"Payment Type"; ARRAYFORMULA(IF(LEN(A2:A), VLOOKUP($A2:A&B2:B,{'S2'!$A$2:A7&'S2'!$B$2:B7, 'S2'!$C$2:C7},2,FALSE),))}

See if that works?



来源:https://stackoverflow.com/questions/52757088/google-sheets-vlookup-inside-arrayformula

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!