+ Reply to Thread
Results 1 to 12 of 12

Add the squares

  1. #1
    Registered User
    Join Date
    03-24-2009
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2002
    Posts
    5

    Add the squares

    How would I add the squares of cells A1:ZZ1 or A1:A1000, without having to do

    =SUM(A1*A1+B1*B1+C1*C1... etc

    This is a basic example of what I actually want to do, but is essentially the same problem.

  2. #2
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848

    Re: Add the squares

    You need to use an array formula.

    Please Login or Register  to view this content.
    confirmed with Ctrl+Alt+Enter instead of just Enter

  3. #3
    Registered User
    Join Date
    03-24-2009
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Add the squares

    Perfect mdbct. Well done!

    Just one correction. It's not ctrl+alt+enter. It's ctrl+SHIFT+enter.

    None the less, that array formula is the shortest anyone can get to.

    Zantier, you can also use the following formula:

    =SUMPRODUCT(A1:A100,A1:A100)

    It gives you exactly the same result. Enjoy!

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Add the squares

    Or =sumsq(a1:a100) entered as a normal formula.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    03-24-2009
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Add the squares

    Even simpler! Cool!

  6. #6
    Registered User
    Join Date
    03-24-2009
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2002
    Posts
    5

    Re: Add the squares

    Is there a general way for me to sum functions applied to a group of cells?

    Say you have a function FN(), and want the sum:

    =SUM(FN(A1)+FN(B1)+FN(C1)....

    Sorry if I'm being a pain.

    EDIT: Thanks for all the quick answers for the summing squares =)

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Add the squares

    Assuming the function is array-compatible, =SUM(FN(A1:C1)) (array entered) or =SUMPRODUCT(FN(A1:C1))

  8. #8
    Registered User
    Join Date
    03-24-2009
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2002
    Posts
    5

    Re: Add the squares

    Thanks for the reply.

    How about if it isn't array compatible?

    I was more thinking for just putting my own calculating in place of the function. e.g:
    indirect("B"+A1) in place of FN(A1)

    I don't know whether/how to make a custom function, and whether it's necessary/helpful to, as I'm very much a newbie.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Add the squares

    How about if it isn't array compatible?
    Then it won't work. Most of the simple built-in functions are, though.
    I was more thinking for just putting my own calculating in place of the function. e.g: indirect("B"+A1) in place of FN(A1)
    That's fine. I'd use INDIRECT sparingly, though -- it's volatile, meaning it recomputes every time Excel calculates, whether it needs to or not.

  10. #10
    Registered User
    Join Date
    03-24-2009
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2002
    Posts
    5

    Re: Add the squares

    Oh, sorry. I ment indirect("B"&A1) in place of FN(A1).

    I tried sum(indirect("B"&B20:B25)), but it just returns #VALUE!

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Add the squares

    You should bring up the Formula Auditing toolbar, select the cell, and then press the Evaluate button repeatedly to watch the formula evaluate step by step. You'll see why it doesn't work.

  12. #12
    Registered User
    Join Date
    03-24-2009
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2002
    Posts
    5

    Re: Add the squares

    Thanks.
    The first evaluation changes it from:
    SUM(INDIRECT("B"&B20:B25)) to
    SUM(INDIRECT("B"&#VALUE!))

    EDIT:I need to go to bed now, but I'll check for any responses in the morning, thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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