+ Reply to Thread
Results 1 to 12 of 12

Sumproduct and indirect syntax

  1. #1
    Valued Forum Contributor
    Join Date
    08-04-2011
    Location
    UK
    MS-Off Ver
    Excel 2021
    Posts
    346

    Sumproduct and indirect syntax

    I've this sumproduct function that works;

    Please Login or Register  to view this content.
    with H60 = MD

    when I replaced the (MD_1=L60) with (INDIRECT(H60&"_1")=L60) it gives #REF! error.

    what have I done wrong please?

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

    Re: Sumproduct and indirect syntax

    Presumably MD_1 and MD_2 are named ranges?

    Pete

  3. #3
    Valued Forum Contributor
    Join Date
    08-04-2011
    Location
    UK
    MS-Off Ver
    Excel 2021
    Posts
    346

    Re: Sumproduct and indirect syntax

    yes, they are

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

    Re: Sumproduct and indirect syntax

    Check that you don't have a space at the end of MD in H60.

    Hope this helps.

    Pete

  5. #5
    Valued Forum Contributor
    Join Date
    08-04-2011
    Location
    UK
    MS-Off Ver
    Excel 2021
    Posts
    346

    Re: Sumproduct and indirect syntax

    no, I even replaced MD with MD_1 in H60, and (INDIRECT(H60)=L60) gives the same error!

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

    Re: Sumproduct and indirect syntax

    Well, without seeing your workbook I can't think of anything else. Do you want to attach it?

    Pete

  7. #7
    Valued Forum Contributor
    Join Date
    08-04-2011
    Location
    UK
    MS-Off Ver
    Excel 2021
    Posts
    346

    Re: Sumproduct and indirect syntax

    well, it's over 30M atm.
    see if I can trim it down.

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Sumproduct and indirect syntax

    Having reconstructed your scenario, with MD in cell H60, these two formulas:

    =SUMPRODUCT(((MD_1=L60)+(MD_1=M60))*((MD_2=L60)+(MD_2=M60)))

    =SUMPRODUCT((((INDIRECT(H60&"_1")=L60)+(INDIRECT(H60&"_1")=M60))*((MD_2=L60)+(MD_2=M60))))

    give precisely the same result.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  9. #9
    Valued Forum Contributor
    Join Date
    08-04-2011
    Location
    UK
    MS-Off Ver
    Excel 2021
    Posts
    346

    Re: Sumproduct and indirect syntax

    on the attached file, formula in U57 to U60 works, but T57 to T60 with indirect that doesn't.

    any suggestions would be very much appreciated.
    Attached Files Attached Files

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Sumproduct and indirect syntax

    I see.

    This is an unfortunate result of Excel not being able to pass a range which is defined dynamically (which yours are) to INDIRECT. If you change the definitions of MD_1 and MD_2 to static references, e.g.:

    =MD!$H$4:$H$121

    and

    =MD!$I$4:$I$121

    then the INDIRECT formulas will work fine.

    Obviously you do not want to lose this dynamism, though. The workaround I know utilizes an old macro-enabled function within Name Manager, called EVALUATE (I presume from your file that you are in any case conversant with VBA).

    I would define two further names in Name Manager, making sure that you do so whilst the active cell in the worksheet is somewhere in row 57 (formulas entered here obey the usual rules re relative/absolute referencing):

    Arry1 as:

    =IF(NOW(),EVALUATE(Data!$H57&"_1"))

    Arry2 as:

    =IF(NOW(),EVALUATE(Data!$H57&"_2"))

    (The initial clause is not strictly necessary, and is also volatile, though the below formula will not automatically recalculate without this volatile addition, even in Automatic Calculation mode. You can remove this clause, though be aware that you will then need to manually force recalculation of these formulas in order to see updated results.)

    The formula in T57 is then:

    =SUMPRODUCT(((Arry1=L57)+(Arry1=M57))*((Arry2=L57)+(Arry2=M57)))

    Regards

  11. #11
    Valued Forum Contributor
    Join Date
    08-04-2011
    Location
    UK
    MS-Off Ver
    Excel 2021
    Posts
    346

    Re: Sumproduct and indirect syntax

    many thanks for your expertise and time.
    i think i stick with the non-dynamic ranges, no big deal.

    thanks again.

  12. #12
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Sumproduct and indirect syntax

    Ok. Sensible choice!

    And you're welcome!

    Regards

+ 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. Indirect() syntax problem
    By 1eyedjack in forum Excel General
    Replies: 9
    Last Post: 04-27-2010, 08:17 AM
  2. dynamic INDIRECT+SUM: syntax help needed
    By Dora C in forum Excel General
    Replies: 3
    Last Post: 02-10-2009, 09:08 AM
  3. Indirect function syntax
    By Myname in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-05-2008, 10:07 PM
  4. what should be syntax for evaluate Indirect
    By srinu1264 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-06-2006, 09:30 AM
  5. [SOLVED] INDIRECT syntax?
    By stephen.reading100 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-21-2005, 09:07 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