IF with INDEX & MATCH

时间:2018-06-18 11:41:18

标签: excel if-statement match

I need to tell my formula to search for one specific value in two different tabs. I currently wrote this (and it's working):

=INDEX(' table (2)'!I2:S727,MATCH('TEST'!P3&'TEST'!Q3,'table (2)'!G2:G727&'table (2)'!H2:H727,0),MATCH('TEST'!R3,'table (2)'!I1:S1,0))

I have two conditions: BLUE and RED.

The above formula is searching for a specific value using BLUE as condition in table (2). I then added:

=IF(N14="BLUE",INDEX(' table (2)'!I2:S727,MATCH('TEST'!P3&'TEST'!Q3,'table (2)'!G2:G727&'table (2)'!H2:H727,0),MATCH('TEST'!R3,'table (2)'!I1:S1,0)))

Works fine.

I would like to make the formula knows that if I want the colour BLUE then search table (2), if I want red then search table (1).

My current spreadsheet has 3 tabs:

TEST = where my workings are
table (1) where RED data is
table (2) where BLUE data is

1 个答案:

答案 0 :(得分:0)

这可能会帮到你。我做的是;

  • 创建名为RED的工作表,在下面创建示例数据:

    enter image description here

  • 创建一个名为BLUE的工作表,在下面创建示例数据:

    enter image description here

  • 在我的普通标签上使用INDIRECT功能,例如:

    enter image description here

所以B2是你在公式中调用的表,B3是搜索值,B3是返回值的实际公式。

因此,要使用此功能,请根据需要更改此公式:

  

= INDEX(INDIRECT(B2&安培;&#34; A:B&#34),MATCH(B3,INDIRECT(B2&安培;&#34; A:A&#34;),0),2)< / p>

祝你好运,

P.S。可能还有其他公式。