Excel Get current row in from sumif statement

2019-08-23 22:46发布

问题:

Im using Excel 2010 and have a datasheet with multiple tabs, this is the current sumif function that i am using

 =IF(SUMIF('Master Data'!$J$2:$J$200,'Resource View (2)'!B22,'Master Data'!$W$2:$W$200)>0,Current_row_different column, "")

Basically I find some rows in the other sheet that have a value of 1 i then want to use these rows that have a value of 1 but use a different column within that row to populate the true condition.

So say for instance row 4 contains a 1 at column A I then want to stay on row 4 but get the value of column B for the true condition.

Is this possible?

Any suggestions much appreciated

Thanks in advance.

EDIT:

I have now managed to get the function working however its a bit of an excel hack, because I have had to move the columns around in the master data and its a bit messy now anyway heres what I've got

 =IF(SUMIF('Master Data'!$C$2:$C$200,'Resource View (2)'!B22,'Master Data'!$W$2:$W$200)>0,VLOOKUP(B22,'Master Data'!$C$2:$F$90,3,FALSE),"")

Now I know this is because VLookup searches through the first column specified and it doesnt seem to work at all if i try to put the range in backwards i.e. $F$90:$C$2 instead of $C$2:$F$90. Is there anyway to manipulate VLOOKUP to work like this?

回答1:

Yes, actually there is a way - a brother of VLOOKUP - it's INDEX(MATCH()). It is a very useful tool, as you can look at any column and return any other, not only looking at the first one to return the ones to the right. Also, INDEX(MATCH()) can be used in forming array formulas, if you need that, while VLOOKUP cannot.

Basically, this part of your formula:

VLOOKUP(B22,'Master Data'!$C$2:$F$90,3,FALSE)

would be changed with this:

INDEX('Master Data'!$E$2:$E$90,MATCH(B22,'Master Data'!$C$2:$C$90,FALSE))

So, after all, the equivalent for

=IF(SUMIF('Master Data'!$C$2:$C$200,'Resource View (2)'!B22,'Master Data'!$W$2:$W$200)>0,VLOOKUP(B22,'Master Data'!$C$2:$F$90,3,FALSE),"")

would be

=IF(SUMIF('Master Data'!$C$2:$C$200,'Resource View (2)'!B22,'Master Data'!$W$2:$W$200)>0,INDEX('Master Data'!$E$2:$E$90,MATCH(B22,'Master Data'!$C$2:$C$90,FALSE)),"")