Nth term of an array formula

Phox

Well-known Member
Joined
Jul 26, 2004
Messages
522
What is the simplest way to get an array formula to return the integer that represents its index? IE, I have an array {John,apple,4,TRUE,7} and I want {1,2,3,4,5} to be the result. Previously, I had been using MATCH(RANGE,RANGE) to obtain this but it backfired when some of the elements in the array were identical. In that case {John,apple,John,TRUE,apple} returns {1,2,1,4,2}. What's the simplest way around this?
 
Last edited:

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
could you tell us what you are trying to achieve with some sample data?? Its hard to imagine the situation from your explanation
 
Upvote 0
I was intentionally trying to generalize so the issue would be simpler and clearer, but the most recent application where I wanted this was in this thread. In this particular case, we were trying to sort a list of names based on their baseball statistics. It's fairly trivial if none of the statistics were the same, but preserving name order when statistics were the same required the knowledge of its relative location in the array.
 
Upvote 0
OK, I figured out a way, but if someone can think of a simpler, shorter answer please share.

DATA is a defined range.
Code:
{=ROW(DATA)-MIN(IF(DATA=INDEX(DATA,1),ROW(DATA),""))+1}
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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