excel match value(get row) in two-dimensional array

天涯浪子 提交于 2020-02-03 05:44:07

问题


I have the following structure in my excel sheet.

          E           F           G        H        
      ---------   ---------    ------    -------      
 2 |  blah        sometext     atext      smth
 3 |  textval     accc
 4 |  test        avfr
 5 |  check       
 6 |  ertyui      
 7 |  

Can you suggest a way using EXCEL functions (not VBA) of getting back the row of a matching string?

For example: given test I need to get back 4, given ertyui 6

I need:

  • the lookup to be done in all the columns of this two-dimensional array and

  • have the function in one cell only


回答1:


With your search string in A1:

=SUMPRODUCT((E2:H6=A1)*ROW(E2:H6))

Obviously this will fail if there is more than one occurrence of the search string within the range. However, each of the values in the dataset you provide is unique, so I presume that this is not an issue.

Besides, if that was a possibility, you would need to clarify which of potentially several different row numbers should be the preferred return.

Regards




回答2:


Maybe with the string sought in say J1, in K1 (the output) something like:

 =SUM(K2:K100)  

and in K2 copied down to say K100:

=IF(ISERROR(MATCH(J$1,E2:I2,0)),"",ROW())



回答3:


Look up examples using =MATCH()

=match("test", E1:E7, 0)

This should return 4. Then modify accordingly.

Better yet, place your condition in some other cell, say A1 and then you could use:

=match($A$1, E$2:E$7, 0)-1

Place that formula in cell E1 and drag across the columns and you'll have a match per each column.



来源:https://stackoverflow.com/questions/26891871/excel-match-valueget-row-in-two-dimensional-array

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