Solved

Excel SUM formula needs variable sheet ranges

Posted on 2014-03-12
6
482 Views
Last Modified: 2014-03-12
We have a mammoth workbook where each sheet represents (and is named for) a week of the year and rows and columns with each sheet show information for individual employees.  I have been asked to create a Summary sheet where one of the things to display is Trailing 13 Weeks table.  I can write a formula which gives me the text value that I am looking for:

=IF(WEEKNUM(TODAY())<WEEKNUM(TODAY()-91),CONCATENATE("WEEK1",":","WEEK",WEEKNUM(TODAY()),"!V55"),CONCATENATE("WEEK",WEEKNUM(TODAY()-91),":","WEEK",WEEKNUM(TODAY()),"!V55")

but if I put that as part of an INDIRECT formula in a SUM formula, it errors out.  I assume that the INDIRECT formula wants an individual cell reference as that is where the error (#REF) happens.  If I leave off the INDIRECT formula, I get a #VALUE error (I assume it reads it as text).

=SUM(INDIRECT(IF(WEEKNUM(TODAY())<WEEKNUM(TODAY()-91),CONCATENATE("WEEK1",":","WEEK",WEEKNUM(TODAY()),"!V55"),CONCATENATE("WEEK",WEEKNUM(TODAY()-91),":","WEEK",WEEKNUM(TODAY()),"!V55")))
0
Comment
Question by:M_Patton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 50

Accepted Solution

by:
barry houdini earned 500 total points
ID: 39923913
Your first formula produces a "3d" reference like

WEEK1:WEEK11!V55

You can't use 3d references with INDIRECT.

You can try producing an "array" of the relevant weeks and use that in a SUMIF fomula. This should work assuming that V55 aren't negative numbers:

=SUMPRODUCT(SUMIF(INDIRECT("WEEK"&ROW(INDIRECT(IF(WEEKNUM(TODAY())<WEEKNUM(TODAY()-91),1,WEEKNUM(TODAY()-91))&":"&WEEKNUM(TODAY())))&"!V55"),">0"))

regards, barry
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39923914
Well the result of your formula is a string !!! I don't think tht is what you want the formula resulted to:
WEEK1:WEEK11!V55

Not even this on an indirect will lead you somewhere !!!

Can you post a small sample of the data I can then fix it for you ?
gowflow
0
 

Author Comment

by:M_Patton
ID: 39923945
I know the first formula results in a string; hence the need for INDIRECT.  It is that string value that would normally be in the SUM formula.

I need the "3d" reference; that is the variable part.

For the YTD table on the same sheet I have a formula that reads =SUM(Week1:Week52!V55)

For the TTW table, I need essentially the same formula result except that instead of it always being weeks 1-52, it needs to reference the previous 13 weeks (or less if we are still in the first quarter).
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 50

Expert Comment

by:barry houdini
ID: 39923973
My suggested formula above is summing V55 in the relevant sheets, but it does it in a different way - rather than creating a 3d reference it produces an "array" like this:

{"WEEK1!V55";"WEEK2!V55";"WEEK3!V55";"WEEK4!V55";"WEEK5!V55";"WEEK6!V55";"WEEK7!V55";"WEEK8!V55";"WEEK9!V55";"WEEK10!V55";"WEEK11!V55"}

You can then use that in a SUMIF fomula to sum V55 on all sheets listed

That will give you the same weeks as your current formula - can you try it?

regards, barry
0
 

Author Closing Comment

by:M_Patton
ID: 39924031
Thanks; the further explanation helped clarify it for me.
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 39924033
I note that as the original logic stands (and I didn't change that with my suggestion) you will normally be summing 14 weeks, e.g. in week 20 your formula will give you

=WEEK7:WEEK20!V55

which is actually 14 different weeks, so if you actually want the last 13 including this week you probably need to change the -91 to -84

regards, barry
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Name Selection and Sorting 43 92
nested If/and formula needed 12 64
Excel formula that pulls back the id 4 40
Help to find the duplicates 8 17
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question