Solved

Excel - Sum two index formulas with a ":"?

Posted on 2010-09-22
7
531 Views
Last Modified: 2012-05-10
Could someone help explain this formula?

=SUM(INDEX(B3:M3,1,MAX(1,COUNT(B3:M3)-2)):INDEX(B3:M3,1,COUNT(B3:M3)))

The first Index will find the value in the Max Count of cells (-2) in the array that are Numeric.  Let's say it's column 6 = value 300.
The second Index does the same but without the "-2", so that's column 8 = value 200.

Those are two values that could be added with a "+".  But the goal of this formula (it does work) is to SUM the range of values from column 6 to column 8.  

This SUM command connects(?) the two Indexes with a ":" -- how does the formula know that means get all of the cells between the two index values?

This question is based on this one:
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_26462331.html?cid=239#a33639089

Thanks for your help.
0
Comment
Question by:billb1057
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 33738260
In Excel, ":" is used to mean between.

Like Sum (A1:A4) = it simply means the contiguous range of cells from A1 to A4 (4)
Or Sum( A1: B10 ) = 20 cells.

So Sum( <first index> : <second index> ) is no different.
You are getting col (3rd to last) and col (last) from B3:M3, so it will sum K3:M3
0
 
LVL 2

Author Comment

by:billb1057
ID: 33738288
Ok, but when I use Index by itself, it just returns the value in one cell.  Does SUM interpret that as the starting point of a range?  So instead of the value, it reads the cell reference?
0
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 200 total points
ID: 33738334
One thing that will help you is to go to the menu/ribbon and in Formula, click on the Evaluate Formula button.  You can then trace through the formula and it will become clear as mud!

INDEX(B3:M3,1,MAX(1,COUNT(B3:M3)-2))
INDEX(B3:M3,1,MAX(1,10))
INDEX(B3:M3,1,10)
K3

The first INDEX actually now refers to the cell K3.
However if you use it on it's own, as if you typed =K3, it obviously doesn't show "K3" but the content of K3, being 300.

The whole formula reduces to

Sum(K3:M3)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 33738345
Technically, INDEX always returns a cell reference.  When you run INDEX "by itself", Excel simply converts that cell reference into that cell's value.  When the context indicates that the INDEX result is the anchor point of a range, then Excel uses it to build that range.
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 33738365
Modification: INDEX returns a range reference.  When that range resolves to a single cell, .Yes, I realize INDEX also works on arrays, but let's leave that out for now :)
0
 
LVL 2

Author Comment

by:billb1057
ID: 33738379
Smart code -- it figures out what context you're using and then adjusts itself for that purpose.  :-)
ciber -- I did try to evaluate what was going on and I knew I needed some secret knowledge for this.  
Many thanks!!
0
 
LVL 2

Author Comment

by:billb1057
ID: 33738386
Thanks, Patrick.  I thought I fully understood it when you first came up with that solution -- little did I know.  :-)
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question