问题
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