Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
709 views
in Technique[技术] by (71.8m points)

excel - Looping a function for multiple lookups

I'm trying to write a formula that search for a part number in a different sheet, and imports all of the times the part had failed inspection. The problem is that I have multiple cases when a part failed, so they fall into different rows. Right now I am able to call up one instance using the following formula;

=INDEX('QN Data'!$A3:$A10000,MATCH($B$4,'QN Data'!$D$3:$D$10000,0))

There are a total of 6 different occurrences that I need transferred. Now is there a way for excel to remember where it left off on and start from there?

Also I cannot use any macros. We currently have one that does all of this, but my boss does not like using them. I tried filling the formula down but it just gives me the QN number that is below the one for the part number I want which is a different part number completely.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can retrieve a multiple match using the AGGREGATE function to force anything that does not match into an error and ignore the errors.

=INDEX('QN Data'!$A$3:$A$10000, AGGREGATE(15, 6, ROW($1:$9998)/('QN Data'!$D$3:$D$10000=$B$4), ROW(1:1)))

You are actually using the SMALL sub-function of the AGGREGATE function so you can get the second, third, etc. successive matches by increasing the k paramter. I done this above by using ROW(1:1) which equals 1 but will increase to 2, 3, etc as the formula is filled down.

The relative row position within 'QN Data'!$A$3:$A$10000 is returned by forcing any row position that does not match into a #DIV/0! error state. The 6 option tells AGGREGATE to ignore errors.

You may wish to put an IFERROR function around the formula so that you can fill down for more rows than necessary without showing #NUM! errors when you run out of matches.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...