问题
How would I combine these together into one?:
=IFERROR(VLOOKUP(B2:B11,Sheet2!A:B,2,FALSE),"No Match")
=IFERROR(VLOOKUP(B3:B12,Sheet2!D:E,2,FALSE),"No Match")
=IFERROR(VLOOKUP(B2:B11,Sheet2!G:H,2,FALSE),"No Match")
These are just three but eventually I would need 12 in total to be joined as these are searching team names and there are 12 teams in total.
回答1:
If you wish to work through each of the pairs of columns in order, for an example of three pairs, just:
=IFERROR(VLOOKUP(B2:B11,Sheet2!A:B,2,0),IFERROR(VLOOKUP(B2:B11,Sheet2!D:E,2,0),IFERROR(VLOOKUP(B2:B11,Sheet2!G:H,2,0),"No Match")))
assuming that it is B2 that is to be your search term (lookup_value) and that the formula above is in Row2. Where ranges are used as the search term in VLOOKUP the row value used is the one in which the formula resides ("implied intercept").
It is generally preferred (eg a tad shorter) to use a version like this instead:
=IFERROR(VLOOKUP(B2,Sheet2!A:B,2,0),IFERROR(VLOOKUP(B2,Sheet2!D:E,2,0),IFERROR(VLOOKUP(B2,Sheet2!G:H,2,0),"No Match")))
and copy the formula down, when B2 adjusts automatically to B3 etc. (Shorter is also why I tend to prefer 0
to FALSE
.)
As mentioned by @Ditto, your data has an unusual layout. Unless you have special reasons for twelve pairs of columns it would appear that just one pair should be sufficient as you seem not to be attempting to place any condition upon which team is searched for which "B2 value". Stacked in ColumnsA:B (by all means with spaces to separate them and labels for the separate teams) there would be no requirement to replicate one of your formulae, this should be sufficient in place of all 12:
=IFERROR(VLOOKUP(B2,Sheet2!A:B,2,0),"No Match")
If it can be guaranteed that a result will be found somewhere (or #N/A
accepted if not, instead of "No Match") this can be further simplified to:
=VLOOKUP(B2,Sheet2!A:B,2,0)
回答2:
=IFERROR(VLOOKUP(B2:B11,Sheet2!A:B,2,FALSE),"No Match")
=IFERROR(VLOOKUP(B3:B12,Sheet2!D:E,2,FALSE),"No Match")
=IFERROR(VLOOKUP(B2:B11,Sheet2!G:H,2,FALSE),"No Match")
Would become:
=IFERROR(VLOOKUP(B2:B11,Sheet2!A:B,2,FALSE), IFERROR(VLOOKUP(B3:B12,Sheet2!D:E,2,FALSE),
IFERROR(VLOOKUP(B2:B11,Sheet2!G:H,2,FALSE),"No Match")
)
)
Ultimately:
=IFERROR(VLOOKUP(B2:B11,Sheet2!A:B,2,FALSE),IFERROR(VLOOKUP(B3:B12,Sheet2!D:E,2,FALSE),IFERROR(VLOOKUP(B2:B11,Sheet2!G:H,2,FALSE),"No Match")))
The result however will still be No Match as "B2:B11" and such are not accepted as Lookup_value inputs with the VLOOKUP function as mentioned by @Ditto.
来源:https://stackoverflow.com/questions/29039736/combine-multiple-vlookups