More elegant than index-match + index-match

bmont

New Member
Joined
May 28, 2013
Messages
14
Office Version
  1. 2016
Platform
  1. MacOS
ABCD
1100200300
2400500600
3700800900

To add line 2 of Head1 and Head3, my go-to would be:

Excel Formula:
=index( B:B, match( 2, A:A, 0)) + index( D:D, match( 2, A:A, 0))

...which seems clunky bc of the repeated matching.

Is there a more elegant way to do this, like what you'd imagine a SUMSIF would do if it existed?
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
With a single match
Excel Formula:
=SUM(INDEX($B:$D,MATCH(2,$A:$A,0),N(IF({1},{1,3}))))
If the data is sorted by column A and it is known that the match criteria will always be found in the list then using approximate match instead of exact would be a better improvement to the formula.

Also you could try limiting it to a realistic number of rows. If you have less then 1000 rows of data then over 99.9% of the match effort is being wasted.
 
Upvote 0
Hi

Also with a single match, try also:
Excel Formula:
=SUM(SUMIF(A:A,2,OFFSET(B:D,,{0,2})))
 
Upvote 0
You can try XLOOKUP, it should do a job if you combine two
 
Upvote 0
@bmont
I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

In relation to version, the simpler version of jasonb75's formula shown in F1 works for me in Excel 365. (Also, since your values in column A are in ascending order and you are looking, exactly, for one of those values you do not need the final argument in the match function)

Whilst it is not as short a formula overall in this case, the new LET function in Excel 365 (not all subscribers have it yet) does allow for a simplification of repetitive calculations within a formula a shown in G1.

20 10 14.xlsm
ABCDEFG
1110020030010001000
22400500600
33700800900
Sum
Cell Formulas
RangeFormula
F1F1=SUM(INDEX(B:D,MATCH(2,A:A),{1,3}))
G1G1=LET(Rw,MATCH(2,A:A),INDEX(B:B,Rw)+INDEX(D:D,Rw))
 
Upvote 0
In relation to version, the simpler version of jasonb75's formula shown in F1 works for me in Excel 365.
Perhaps one of the benefits of dynamic arrays, it doesn't work in 2019 without the extra coercion.
 
Upvote 0
.. it doesn't work in 2019 without the extra coercion.
I assumed that was the case hence my reference to the significance of version information, but thanks for the confirmation.
 
Upvote 0
I'd hope to see solutions posted for all versions, irrespective of my own. Indeed, I still learn stuff from million-year-old posts, so LET(rip) your advanced-version posts!

That said, still wondering if there's a solution that would behave like what you'd expect from a SUMSIF function, a la IF( INDEX(rangeA)=TRUE, SUM( INDEX(rangeB) and INDEX(rangeC), 0).

Also, =IF("rephrasing the question"<>OK,"sorry, i'm noob",(y))
 
Upvote 0

Forum statistics

Threads
1,215,036
Messages
6,122,796
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top