# Excel/formula error

Question
Hi Tom

I have just written this formula.  Unfortunately it returns an error could you have a look at it and tell where I have gone wrong?

=if(L1="aut 1"),AVERAGEIF(Sheet7!B5:B1249,B32,Sheet7!I5:I1249,if(L1="aut 2"),AVERAGEIF(Sheet7!B5:B1249,B32,Sheet7!S5:IS249, if(L1="Spr 1"),AVERAGEIF(Sheet7!B5:B1249,B32,Sheet7!AC5:AC1249,if(L1="Spr 2"),AVERAGEIF(Sheet7!B5:B1249,B32,Sheet7!AM5:AM1249,if(L1="Sum 1"),AVERAGEIF(Sheet7!B5:B1249,B32,Sheet7!AW5:AW1249,if(L1="Sum 2"),AVERAGEIF(Sheet7!B5:B1249,B32,Sheet7!BG5:BG1249,""))))))

Chris Mitchell

Christopher Mitchell,

You don't need a right paren after you condition in the IF statements since there is only a single condition.  You also did not close out the AverageIF function with a right paren.

also, I noticed in this statement
AVERAGEIF(Sheet7!B5:B1249,B32,Sheet7!S5:IS249

you say S4 to IS249 so I believe that should be  S4:S1249 - I have put that correction in the below as well

this appears to balance properly:

=IF(L1="aut 1",AVERAGEIF(Sheet7!B5:B1249,B32,Sheet7!I5:I1249),IF(L1="aut 2",AVERAGEIF(Sheet7!B5:B1249,B32,Sheet7!S5:S1249), IF(L1="Spr 1",AVERAGEIF(Sheet7!B5:B1249,B32,Sheet7!AC5:AC1249),IF(L1="Spr 2",AVERAGEIF(Sheet7!B5:B1249,B32,Sheet7!AM5:AM1249),IF(L1="Sum 1",AVERAGEIF(Sheet7!B5:B1249,B32,Sheet7!AW5:AW1249),IF(L1="Sum 2",AVERAGEIF(Sheet7!B5:B1249,B32,Sheet7!BG5:BG1249),""))))))

--
Regards,
Tom Ogilvy

Questioner's Rating
 Rating(1-10) Knowledgeability = 10 Clarity of Response = 10 Politeness = 10 Comment As ever, thank you. Chris Mitchell

• Ask a Question
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.