Consulting

Results 1 to 6 of 6

Thread: Solved: Sum or Sumproduct help

  1. #1
    VBAX Tutor lynnnow's Avatar
    Joined
    Jan 2005
    Location
    Mumbai, Maharashtra, India
    Posts
    299
    Location

    Solved: Sum or Sumproduct help

    Hi Guys,

    I've got a sheet with two columns per date, i.e., Mins and WC.

    I need to horizontally sum the Mins and WC separately at end of the table.

    The SUM formula allows for only 30 items. I've been reading the SUMPRODUCT article by XLD but still need to get my head around the subject.

    Alternatively, I can use the "+" symbol, but considering the difference in the number of days of each month, updating the formula and maybe even missing out a column can lead to a wrong result. Will SUMPRODUCT work for this? Is there any other way?

    I'm using Excel 2003 on Win XP.

    I'm attaching some sample data.

    Thanks in advance.

    Lincoln
    Attached Files Attached Files

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Use

    =SUMPRODUCT(--(MOD(COLUMN($B4:$BK4),2)=0),$B4:$BK4)

    and

    =SUMPRODUCT(--(MOD(COLUMN($B4:$BK4),2)=1),$B4:$BK4)
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    In BL4:
    =SUMIF($B$3:$BK$3,BL$3,$B4:$BK4)
    then copy across and down.
    Be as you wish to seem

  4. #4
    VBAX Tutor lynnnow's Avatar
    Joined
    Jan 2005
    Location
    Mumbai, Maharashtra, India
    Posts
    299
    Location
    Absolutely fabulous answers, both of you!!!

    Bob, I'm stunned with your sumproduct formula. Please explain how it works. I tried stepping thru the formula, but can't seem to understand how the formula works.

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Basically, my formula looks at each column and checks whether it is an even number column MOD(COLUMN($B4:$BK4),2)=0, or an odd numbered column MOD(COLUMN($B4:$BK4),2)=1.

    That part of the formula will return an array of TRUE,FALSE,TRUE,FALSE,... and FALSE,TRUE,FALSE,TRUE,... (note the difference), which is converted to arrays of 1,0,1,0,... and 0,1,0,1,... by the double unary, --. This is then multiplied by the actual values, so it is just adding up every other value.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    VBAX Tutor lynnnow's Avatar
    Joined
    Jan 2005
    Location
    Mumbai, Maharashtra, India
    Posts
    299
    Location
    Thanks Bob, I had understood the column part, the unary bit threw me off and couldn't make sense of the rest. Thank you once again.

Posting Permissions

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