+ Reply to Thread
Results 1 to 7 of 7

Mixing INDIRECT & ADDRESS with SUMPRODUCT - Confusion with Strings

  1. #1
    Registered User
    Join Date
    12-04-2012
    Location
    Orange, Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Mixing INDIRECT & ADDRESS with SUMPRODUCT - Confusion with Strings

    Hello all

    My problem is I need to use the SumProduct function on variable length arrays. Hence I believe I need to use the Indirect function together with a string address as the parameters of the SumProduct function.

    I am assembling the array address string using the Address function and given it is an array, I'm concatenating the address as follows (I've replaced various formulas etc with hard-coded numbers for simplicity):
    Please Login or Register  to view this content.
    Straightforward so far.

    Testing on its own, it produces the string "$B$3:$B$7" as expected.

    The problem is when I apply it to the INDIRECT formula as follows
    Please Login or Register  to view this content.
    I get a #VALUE! error

    But when I replace the COLUMN(B3) formula's with hard coded numbers
    Please Login or Register  to view this content.
    all is good.

    A clue might be that when using the in-cell debugging feature of Excel, the hard-coded Indirect function evaluates to a 5 element array {1;2;3;4;5} while the first Indirect function evaluates to a single element array {1}. But why?


    I'm new to this forum and in fact have not been on any forums for many years. Hence apologises if I violate any protocols - constructive criticism very welcome.

    I have a guru colleague working on it. If she finds a solution, I'll post.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Mixing INDIRECT & ADDRESS with SUMPRODUCT - Confusion with Strings

    First thoughts ...
    .
    Avoid volatile functions such as INDIRECT() and ADDRESS() when trying to define dynamic ranges.

    Post a sample of your workbook showing your layout and the expected result and we'll see where that takes us other "Gurus".
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  3. #3
    Registered User
    Join Date
    12-04-2012
    Location
    Orange, Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Mixing INDIRECT & ADDRESS with SUMPRODUCT - Confusion with Strings

    I found a couple of alternative solutions that got around this problem. The first involved breaking the Address concatenation calculation out into separate cells and the other involved restructuring the data and using the SUMIF function. Both involved a lot of extra columns for intermediate calculations.

    There are usually alternative solutions to most problems but I would like to understand the core issue in the problem I posed above. I'm sure there is revealing insight to be had.

  4. #4
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Mixing INDIRECT & ADDRESS with SUMPRODUCT - Confusion with Strings

    hi apembo, welcome to the forum. like you, i would also love to know what went wrong with my solution rather than getting an alternative. it seems that SUMPRODUCT doesn't go very well with INDIRECT & COLUMN. that's just my guess of course. but since you mentioned about your alternatives needing separate & extra columns, here's one that don't:
    =SUMPRODUCT(OFFSET(B$3,,,5),Q3:Q7)

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  5. #5
    Registered User
    Join Date
    12-04-2012
    Location
    Orange, Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Mixing INDIRECT & ADDRESS with SUMPRODUCT - Confusion with Strings

    Quote Originally Posted by benishiryo View Post
    hi apembo, welcome to the forum. like you, i would also love to know what went wrong with my solution rather than getting an alternative. it seems that SUMPRODUCT doesn't go very well with INDIRECT & COLUMN. that's just my guess of course. but since you mentioned about your alternatives needing separate & extra columns, here's one that don't:
    =SUMPRODUCT(OFFSET(B$3,,,5),Q3:Q7)
    Thanks benishiryo. That's actually perfect - appreciated. Much more elegant than what I was attempting.

    I believed I've uploaded a canned example illustrating my issue and with your solution to assist others.

    Thats the second time I've used the OFFSET function - I will have to keep it mind.

    Again excellent - thanks all.
    Attached Images Attached Images
    Attached Files Attached Files

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Mixing INDIRECT & ADDRESS with SUMPRODUCT - Confusion with Strings

    It's COLUMN function that causes the problem - as you discovered it returns an "array" like {2} rather than a number 2 - sometimes that doesn't matter but some functions can't process that array as needed. One option is to wrap COLUMN in another function like SUM, so I wouldn't propose this as a viable solution to your problem (because there are better ways) but this version should work nevertheless

    =SUMPRODUCT(INDIRECT(ADDRESS(3,SUM(COLUMN(B3)))&":"&ADDRESS(7,SUM(COLUMN(B3)))),Q3:Q7)
    Audere est facere

  7. #7
    Registered User
    Join Date
    12-04-2012
    Location
    Orange, Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Mixing INDIRECT & ADDRESS with SUMPRODUCT - Confusion with Strings

    Quote Originally Posted by daddylonglegs View Post
    It's COLUMN function that causes the problem - as you discovered it returns an "array" like {2} rather than a number 2 - ...
    Aaaaahh - thats the eureka moment I was hoping for.

    I just went and applied the column function as follows:
    Please Login or Register  to view this content.
    and it returns 3, but when you delve in, it's actually returned a 4 element horizontal array {3,4,5,6}

    Brilliant. Thankyou

    PS: arrays are one area of Excel I have largely ignored. My curiosity is aroused ...

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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