+ Reply to Thread
Results 1 to 12 of 12

Sum dynamic range in closed workbook using address/match

  1. #1
    Registered User
    Join Date
    08-05-2013
    Location
    USA
    MS-Off Ver
    2010
    Posts
    76

    Sum dynamic range in closed workbook using address/match

    Hello all,

    I am trying to sum a variable date range, but the data is in another file and I don't want to open it every time. I noticed when I use =SUM('[file folder]\[file name]Worksheet'!$A$1:'[file folder]\[file name]Worksheet'!$A$3), it returns an error, but if I use =SUM'[file folder]\[file name]Worksheet'!$A$1:$A$3) it would sum correctly. I assume Excel cannot handle two file paths in a range, despite that they are the same file path.

    I hoped that if I can find out the starting and ending cell addresses of the range, I may be able to find a solution. I used =ADDRESS(MATCH) to identify the starting and ending cell addresses, and I know the file path, so I wrote a formula to put it all together in G1 so that it reads '[file folder]\[file name]Worksheet'!$A$1:$A$3. However, I can't find a way to =SUM(G1).

    I've read in other forums that it's impossible to sum a dynamic range, but I haven't found anyone trying to use the actual cell addresses to hard code the range. Any help is appreciated. Thanks a bunch!

    -J

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,942

    Re: Sum dynamic range in closed workbook using address/match

    Hi and welcome to the forum

    Try this instead.

    In the "other" workbook, create your sum() formula in a cell there, and then just reference that cell from the 1st WB> That way, you dont have to worry about referencing closed workbooks
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    08-05-2013
    Location
    USA
    MS-Off Ver
    2010
    Posts
    76

    Re: Sum dynamic range in closed workbook using address/match

    Thanks FDibbins,

    I agree that would be the ideal way, but I don't have writing privileges to the "other" workbook. The other workbook is submitted to me and cannot be modified. Only if it were that easy!

    I get 30 or so of these other workbooks, which I have to extract and compile, which is why I'd rather not open every one every time I need to make a calculation. And the range is specified on my workbook, so I won't always be referencing the same range in the other workbooks.

  4. #4
    Registered User
    Join Date
    08-05-2013
    Location
    USA
    MS-Off Ver
    2010
    Posts
    76

    Re: Sum dynamic range in closed workbook using address/match


  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Sum dynamic range in closed workbook using address/match

    Can't you just refer to the entire column?

    Something like:

    =SUM('C:\[File.xls]Sheet1'!A:A)
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Registered User
    Join Date
    08-05-2013
    Location
    USA
    MS-Off Ver
    2010
    Posts
    76

    Re: Sum dynamic range in closed workbook using address/match

    No because there is other information in that column, but thank you Tony.

    I think I need to clarify. I receive multiple reports that I cannot edit. Each report has 5 data sets, one stacked on top of the other, with a total row for each data set. I forget which row the total columns are, but they sum everything above it in that particular data set. I've attached an example with just the total rows. At the very top of the data sets is the month for which the data below corresponds.

    On a new workbook, I need to sum each of the totals from all of these many workbooks that I receive, but I only need the totals based on a date range that I, or another user, sets. For example, I may need to sum Total 2 for Companies A through Z (Companies A through Z are all on separate workbooks), for the months of Jun 2012 - Oct 2012. Any idea how I can do that when the data workbooks are closed?

    I placed a start date and end date on the new workbook and tried using sum with index/match to find the date range in each of the data workbooks, but it returns an error because Excel cannot handle two file paths when summing a range. That's why I've been playing with the index/address function to see if that works. Please feel free to ask me questions if I'm still not clear enough to describe what I'm trying to do. Thanks!
    Attached Files Attached Files

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Sum dynamic range in closed workbook using address/match

    Maybe something like this...

    To get the sum of Total 2 within the date range 6/1/2012 thru 10/1/2012:

    Sheet2:

    A1 = Total 2
    B1 = 6/1/2012
    C1 = 10/1/2012

    This formula entered in D1:

    =SUM(INDEX(Sheet1!B2:Y6,MATCH(A1,Sheet1!A2:A6,0),MATCH(B1,Sheet1!B1:Y1,0)):INDEX(Sheet1!B2:Y6,MATCH(A1,Sheet1!A2:A6,0),MATCH(C1,Sheet1!B1:Y1,0)))

  8. #8
    Registered User
    Join Date
    08-05-2013
    Location
    USA
    MS-Off Ver
    2010
    Posts
    76

    Re: Sum dynamic range in closed workbook using address/match

    This works perfectly, but only if I keep the workbook open to perform the calculation. I get a #REF! error if the source workbook is closed and I think its because Excel cannot handle two file paths where there's a range in the sum function. I was hoping I could avoid opening the source workbooks since I have so many of them.

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Sum dynamic range in closed workbook using address/match

    I'm going to be away for a couple of hours but I'll get back to you with something else that should work.

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Sum dynamic range in closed workbook using address/match

    Try something like this...

    In some other file...

    A1 = Total 2
    B1 = 6/1/2012
    C1 = 10/1/2012

    Enter this formula in D1:

    =SUMPRODUCT(('C:\[Example.xlsx]Sheet1'!A2:A6=A1)*('C:\[Example.xlsx]Sheet1'!B1:Y1>=B1)*('C:\[Example.xlsx]Sheet1'!B1:Y1<=C1)*'C:\[Example.xlsx]Sheet1'!B2:Y6)

    Use the appropriate path.

  11. #11
    Registered User
    Join Date
    08-05-2013
    Location
    USA
    MS-Off Ver
    2010
    Posts
    76

    Re: Sum dynamic range in closed workbook using address/match

    You sir, are a Genius! I cannot express thank you enough! Seriously, EPIC work!

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Sum dynamic range in closed workbook using address/match

    You're welcome. Thanks for the feedback!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Using Index and Match functions on a closed workbook
    By Driz in forum Excel General
    Replies: 5
    Last Post: 06-23-2017, 02:13 AM
  2. quickest method for dynamic link to closed workbook
    By bangelta in forum Excel General
    Replies: 0
    Last Post: 10-25-2012, 02:53 PM
  3. Copy dynamic range from closed workbook
    By RedWing in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-08-2011, 07:11 PM
  4. Dynamic Range, Data Validation and Address, Match and Offset Funct
    By rudawg in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-28-2006, 11:25 PM
  5. refer to dynamic range in closed workbook with ADO
    By MattShoreson in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-13-2005, 06:26 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1