You are here:

# Excel/Referencing a named range in a formula

Question
QUESTION: Hi Tom,

Using Excel 2010.
I am using the following formula:
=SUMIFS('Dan'!E:E,'Dan'!D:D,\$A43,'Dan'!C:C,\$B43)+SUMIFS('Drew'!E:E,'Drew'!D:D,\$A43,'Drew'!C:C,\$B43)+SUMIFS('Ed'!E:E,'Ed'!D:D,\$A43,'Ed'!C:C,\$B43)+SUMIFS('Keith'!E:E,'Keith'!D:D,\$A43,'Keith'!C:C,\$B43)+SUMIFS('Mark'!E:E,'Mark'!D:D,\$A43,'Mark'!C:C,\$B43)+SUMIFS('Steve'!E:E,'Steve'!D:D,\$A43,'Steve'!C:C,\$B43)+SUMIFS('Tom'!E:E,'Tom'!D:D,\$A43,'Tom'!C:C,\$B43)

Which totals up some parts used, and displays the results according to customer & date. In order to simplify editing the spreadsheet, is it possible to reference a named range (in this case "SheetNames") in the formula, instead of using the above?

=SUM(SUMIFS(INDIRECT(SheetNames&"!E:E"),INDIRECT(SheetNames&"!D:D"),\$A43,INDIRECT(SheetNames&"!C:C"),\$B43))

entered with Ctrl+Shift+Enter  worked for me.

or

=SUMPRODUCT(SUMIFS(INDIRECT(SheetNames&"!E:E"),INDIRECT(SheetNames&"!D:D"),\$A43,INDIRECT(SheetNames&"!C:C"),\$B43))

entered normally.

Name:  SheetNames
Refersto:  ={"Dan","Drew","Ed","Keith","Mark","Steve","Tom"}

If I changed the sheet name of Keith to be Kei th (with an embedded space) so that the name would need to be in single quotes, then I redefined Sheetnames to be

={"Dan","Drew","Ed","'Kei th'","Mark","Steve","Tom"}

and it worked for me as well.

--
Regards,
Tom Ogilvy

---------- FOLLOW-UP ----------

QUESTION: Thanks Tom.

I am getting a #REF! error. One thing I forgot to mention, the named range "SheetNames" is on a separate sheet called "Index". Could this affect the formula?

Steve,

I added a sheet named index and typed in the names in a single column.  I named the range of names Sheetname1 (I used a slightly different name since I was keeping the other list as well).  I then modified the formula

=SUMPRODUCT(SUMIFS(INDIRECT(Sheetnames1&"!E:E"),INDIRECT(Sheetnames1&"!D:D"),\$A43,INDIRECT(Sheetnames1&"!C:C"),\$B43))

and it worked for me.

D5:D11 on Sheet Index

Dan
Drew
Ed
'Kei th'
Mark
Steve
Tom

note that 'Kei th'  is entered as  ''Kei th'

since the first single quote is interpreted as a formatting character.

Make sure that your SheetNames is a workbook level name and not a sheet level name.  Check the spelling of the names as well.

--
Regards,
Tom Ogilvy
Questioner's Rating
 Rating(1-10) Knowledgeability = 10 Clarity of Response = 10 Politeness = 10 Comment Thanks Tom! I wasn't sure why you were demonstrating the effects of changing Keith to Kei th, but I understand now how it affects the range reference when a space between the first & last name is used (I did strip the last names from the formula I sent to you.) I changed the 2 examples you sent to: =SUM(SUMIFS(INDIRECT("'"&SheetNames&"'"&"!E:E"),INDIRECT("'"&SheetNames&"'"&"!D:D"),\$A43,INDIRECT("'"&SheetNames&"'"&"!C:C"),\$B43)) and: =SUMPRODUCT(SUMIFS(INDIRECT("'"&SheetNames&"'"&"!E:E"),INDIRECT("'"&SheetNames&"'"&"!D:D"),\$A44,INDIRECT("'"&SheetNames&"'"&"!C:C"),\$B44))

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.