# Excel/formula rewrite

Question
Hi Tom

I have a student whose name is written in worksheet "SPtemplate2" cell  "i2".  The following formula is written in cell "i7"

=IFERROR(INDEX(Sheet2rng!\$A\$1:\$AG\$2500,MATCH(I2,Sheet2rng!\$A\$1:\$A\$2500,0),MATCH("Target",Sheet2rng!\$A\$1:\$AG\$1,0)),"")

The formula works i.e it will look for the student's target grade in "Sheet2rng" and return it in cell "i7"

However on Sheet2rng the student appears twice because they are in two different classes.  I would like to alter the formula so that cell i7 will produce the student's target grade according to the class that they are in.

The student's class is referenced in cell "x3" on worksheet "SPtemplate2".  Column "S" in worksheet "Sheet2rng" contains the list classes for each student.

Is this possible and if so could you alter the formula for me?

Chris Mitchell

Christopher Mitchell,

If the grade is a number, then you could use SUMIFS with two conditions that make the row unique so only that single grade would be summed.  If the grade is alphanumeric then you would probably need an array formula.

There are several different ways to use an array formula for this.  This is one way:

=IFERROR(INDEX(Sheet2rng!\$A\$1:\$AG\$2500,MATCH(I2&x3,Sheet2rng!\$A\$1:\$A\$2500&Sheet2rng!\$S\$1:\$S\$2500,0),MATCH("Target",Sheet2rng!\$A\$1:\$AG\$1,0)),"")

Entered with Ctrl+Shift+enter rather than just enter.

--
Regards,
Tom Ogilvy
Questioner's Rating
 Rating(1-10) Knowledgeability = 10 Clarity of Response = 10 Politeness = 10 Comment Perfect. Thank you.

This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

#### Tom Ogilvy

##### Expertise

Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]

##### Experience

Extensive experience.

Education/Credentials
Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.