Excel, Search two columns for different values on the same row, return results from a cell in that row

五迷三道 提交于 2019-12-13 09:06:26

问题


I'm trying to make a search through a data sheet to fill in cells that will be printed as a chart.

The search will need to match two criteria that are on the same row, then return the value from another cell in that same row. It will look for a week# and location on the same row, then return a score that is several columns down on that row.

My intention was to use a a couple LOOKUP with an AND statement to build some kind of megafunction. Like IF(AND(VLOOKUP($H$27,B:B,"",FALSE)<>(VLOOKUP($G$26,C:C,42,FALSE))) I would need both of the search criteria to match before it returned the value from column 42.

Week# and score for the X&Y of the chart. You would input the location in a cell($G$26) for the search and it would populate the cells for the chart. Each reference cell in the chart would use the formula with the only difference being what week it looks at.

I willing to accept that I may be going about this in a terrible way.


回答1:


The syntax for VLOOKUP is VLOOKUP(lookup_value,table_array,col_index_num,range_lookup) where lookup_value must be a single criterion. The simplest solution to look up a result based on multiple criteria can be to convert multiple criteria into a single criterion, with concatenation. Instead of trying to find a match for “John where also Smith”, string the two together (eg =A1&B1) and seek to match “John Smith”. To avoid corrupting the source data this usually means adding a helper column to contain =A1&B1 (or a helper row in case of HLOOKUP and say =A1&A2). The table_array may also require an additional column (or row) to hold values such as "John Smith".




回答2:


See if the explanation at this link is of any help: http://spreadsheets.about.com/od/lookupfunction1/ss/2011-03-03-excel-2010-vlookup-multiple-values-sbs-tutorial_10.htm.

According to that explanation your formula should be something like =INDEX($A:$AP,MATCH($H$27&$G$26,$B:$B&$C:$C,0),42)

After you enter that formula - just before you hit the Enter key - press Ctrl-Shift-Enter to make this an array formula. The link explains it more in detail when checking all intermediate steps.



来源:https://stackoverflow.com/questions/18880744/excel-search-two-columns-for-different-values-on-the-same-row-return-results-f

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