简体   繁体   English

Excel使用INDEX和多个MATCH

[英]Excel using INDEX and multiple MATCH

I am having trouble using INDEX and MATCH functions in excel. 我在Excel中使用INDEX和MATCH函数时遇到问题。 Say I have the following data: 说我有以下数据:

A        B       C      D
Year   Month   Site   Count
2004     3      X1      54
2006     6      X3      10
2005     10     X5      15

And I want to arrange it like this 我想这样安排

E        F      G       H      I      J       K
Year   Month    X1      X2     X3     X4      X5
2004     1
2004     2
2004     3      54            
2004     4
2004     5
2004     6

... ...

2005     10                     10   

... ...

2006     6                                   15

I have the following formula (I want to match the Site, Year and Month): 我有以下公式(我想匹配站点,年份和月份):

=IFERROR(INDEX($D$2:$D$4,MATCH(G$1,$C$2:$C$4,0),MATCH($E2,$A$2:$A$4,0),MATCH($F2,$B$2:$B$4,0)),"")

and it seems to work fine for the first column (G) but when I autofill the rest of the columns (H:K) it doesn't work. 并且似乎在第一列(G)上正常工作,但是当我自动填充其余列(H:K)时,它不起作用。 Any ideas? 有任何想法吗? Thanks. 谢谢。

I'd take a different approach than using all these nested matches, and create a searchable column with unique values and MATCH that column to get a row to feed into the INDEX . 我将采用与使用所有这些嵌套匹配项不同的方法,并创建一个具有唯一值的可搜索列,并MATCH该列以获取要馈入INDEX的行。

Insert 2 rows between Cols D and E, putting the 2nd appearance of 'Year' in Column G. (Because I like some whitespace) 在第D列和第E列之间插入两行,将“ Year”的第二次出现放在G列中。(因为我喜欢一些空白)

Paste this formula in E2 and copy it to E3:E4 将此公式粘贴到E2中并将其复制到E3:E4

=CONCATENATE(C2,"-",A2,"-",B2)

If it bothers you, hide Column E. 如果您不满意,请隐藏E列。

Then paste this formula in I2 and copy it to I2:M4: 然后将此公式粘贴到I2中并将其复制到I2:M4:

=IFERROR(INDEX($D$2:$D$4,MATCH(CONCATENATE(I$1,"-",$G2,"-",$H2),$E$2:$E$4,0),0),"")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM