简体   繁体   中英

find the index of an array function in excel

I have been working on a shortest path problem in excel (see image below) with dynamic programming. I got the numbers. However, I can't find a way to also find the index of the minimum number the path belongs to.

The formula loops over the row and column element-wise, and adds them together. Finally, it fins the minimum value.

For example: the highlighted cell (A15) has the answer 9 (minimum value = 5+4) Now I want to add the column name of this minimum value: C.

I am not an excel expert and have no idea how to do this. Any help is much appreciated!

在此处输入图像描述

It should be an index/match formula ie first find the position of the minimum value in the array using Match, then find the corresponding letter in the header row using Index:

=INDEX($B$11:$G$11,MATCH(MIN(TRANSPOSE(B$2:B$7)+$B14:$G14),TRANSPOSE(B$2:B$7)+$B14:$G14,0))

Note if ties are possible, this will find the first match.

In my version of Excel, this has to be entered as an array formula using Ctrl Shift Enter

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM