+ Reply to Thread
Results 1 to 11 of 11

Summing a Named Range when said name is being pulled from another cell

Hybrid View

  1. #1
    Registered User
    Join Date
    06-06-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    29

    Summing a Named Range when said name is being pulled from another cell

    Hi all,

    I would like to do the following:

    Cell "A1" - Apples/Orange/Bananas (these are all named ranges in my workbook)

    Cell "B1" = sum(range mentioned in cell "A1") <- currently all this does is return the sum of A1 which is 0 or #NAME.


    Thoughts?

    Thanks!

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,427

    Re: Summing a Named Range when said name is being pulled from another cell

    If you only had one name in A1, then you could do this in B1:

    =SUM(INDIRECT(A1))

    However, it will need to be a lot more sophisticated if you have more than one name in A1 separated by /.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    06-06-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    29

    Re: Summing a Named Range when said name is being pulled from another cell

    Quote Originally Posted by Pete_UK View Post
    If you only had one name in A1, then you could do this in B1:

    =SUM(INDIRECT(A1))

    However, it will need to be a lot more sophisticated if you have more than one name in A1 separated by /.

    Hope this helps.

    Pete
    Pete, your the best. I didn't even think to try that. Can't tell you how happy I am! Just out of curiosity, because it very well might come up in the future, how would i need to go about summing up multiple named ranges? A macro would take too long. I don't like lag.

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,427

    Re: Summing a Named Range when said name is being pulled from another cell

    I would not advise it. Suppose you had two names in A1 separated by a /, then you could use this:

    =SUM(INDIRECT(LEFT(A1,FIND("/",A1)-1))) + SUM(INDIRECT(RIGHT(A1,LEN(A1)-FIND("/",A1))))

    With 3 names you would need 3 terms, with a LEFT, MID and RIGHT term to get the names, and if there were a variable number of names then you would need IFs to generate the correct sum - I suppose by "sophisticated" I really meant "complicated".

    Hope this helps.

    Pete

    P.S. If that takes care of your original question, please select Thread Tools from the menu above your first post and mark this thread as SOLVED.

    Also, since you are relatively new to the forum, you might like to know that you can directly thank those who have helped you by clicking on the small "star" icon located in the lower left corner of a post that you have found to be helpful (not just in this thread - for any post that has helped you). This also adds to the reputation of the poster (the small green bars in the poster's profile).

    Pete

  5. #5
    Registered User
    Join Date
    06-06-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    29

    Re: Summing a Named Range when said name is being pulled from another cell

    Quote Originally Posted by Pete_UK View Post
    I would not advise it. Suppose you had two names in A1 separated by a /, then you could use this:

    =SUM(INDIRECT(LEFT(A1,FIND("/",A1)-1))) + SUM(INDIRECT(RIGHT(A1,LEN(A1)-FIND("/",A1))))

    With 3 names you would need 3 terms, with a LEFT, MID and RIGHT term to get the names, and if there were a variable number of names then you would need IFs to generate the correct sum - I suppose by "sophisticated" I really meant "complicated".

    Hope this helps.

    Pete

    P.S. If that takes care of your original question, please select Thread Tools from the menu above your first post and mark this thread as SOLVED.

    Also, since you are relatively new to the forum, you might like to know that you can directly thank those who have helped you by clicking on the small "star" icon located in the lower left corner of a post that you have found to be helpful (not just in this thread - for any post that has helped you). This also adds to the reputation of the poster (the small green bars in the poster's profile).

    Pete
    Are you not advising the formula? or using a macro to replicate the formula? I don't see any downfalls especially if I begin the formula with if(isnumber(search("*/*")),.....

    I appreciate your help on this.

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

    Re: Summing a Named Range when said name is being pulled from another cell

    Just for the challenge and the academic exercise...

    A1:A5 = named range Apples
    B1:B5 = named range Oranges

    D1 = Apples, Oranges

    To get the sum of the named ranges entered in D1:

    =SUMPRODUCT(SUMIF(INDIRECT(INDEX(TRIM(MID(SUBSTITUTE(D1,", ",REPT(" ",99)),(99*(ROW(INDIRECT("1:"&LEN(D1)-LEN(SUBSTITUTE(D1,",",""))+1))-1))+1,99)),0)),">-1000000"))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  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: Summing a Named Range when said name is being pulled from another cell

    Quote Originally Posted by newfrito11 View Post
    Is there a reason yours would work better than Pete's?
    If there will only be a few ranges Pete's suggestion is better.

    If there will be "many" ranges then I would put each range name in its own cell...

    A1:A5 = named range Apples
    B1:B5 = named range Oranges
    D1:D2 = the range names

    Data Range
    A
    B
    C
    D
    E
    1
    23
    94
    Apples
    616
    2
    47
    66
    Oranges
    3
    90
    86
    4
    57
    37
    5
    75
    41
    6
    ------
    ------
    ------
    ------
    ------


    This formula entered in E1:

    =SUMPRODUCT(SUMIF(INDIRECT(D1:D2),">-1000000000"))

    Quite a difference, eh?

    The other formula was just to see if it could be done.

  8. #8
    Registered User
    Join Date
    06-06-2015
    Location
    USA
    MS-Off Ver
    2010
    Posts
    29

    Re: Summing a Named Range when said name is being pulled from another cell

    Tony,

    Would you mind talking me through your formula? mainly the >-100000000 portion

  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: Summing a Named Range when said name is being pulled from another cell

    The >-100000000 is the SUMIF criteria.

    We want a simple sum of the named ranges but the SUM function won't accept the array of named ranges so we have to use the SUMIF function as an alternative.

    The SUMIF function requires a criteria so I arbitrarily used >-100000000 which means greater than negative 100 million. There's a pretty good chance that your numbers will meet that criteria.

+ 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] Assign named range to one cell depending on named range in another
    By x65140 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-22-2015, 11:04 AM
  2. [SOLVED] determining if cell is part of named range and what that named range is
    By stnkynts in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-16-2014, 07:56 PM
  3. [SOLVED] Determining if the value of a cell can be a named range, then assigning named ranges after
    By Romulo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-15-2013, 06:05 PM
  4. Avg values for multiple cells pulled from named list...?
    By rtilghman in forum Excel General
    Replies: 3
    Last Post: 02-03-2010, 11:43 AM
  5. summing up from a set cell to a named cell
    By philmetz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-11-2009, 10:50 AM
  6. Replies: 1
    Last Post: 06-03-2006, 10:55 PM
  7. If any cell in named range = 8 then shade named range
    By JJ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-26-2005, 07:05 PM

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