Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9843

Simplest way to return header of max value in a row (for a dynamic range)?

$
0
0

I have a sheet with a table, where I want to extract the header of the max value in each row. The simple solution for that is:

=IFERROR(IF(AND(B2<>"Sa",B2<>"Su"),INDEX($C$1:$Y$1,MATCH(MAX(C2:Y2),C2:Y2,0)),"weekend"),"")

Problem is, that if you insert a column to the right on column Y, the formula will not change the range (it will still be C2:Y2, and data on column Z will not be included). For that I created this formula, which solves this issue:

=iferror(if(AND(B2<>"la";B2<>"su");INDEX($C$1:$1;MATCH(MAX(INDIRECT("C"&row()&":"&SUBSTITUTE(ADDRESS(1;MATCH(OFFSET(INDIRECT(ADDRESS(1;COLUMN()));0;-5);$1:$1;0)-1;4);1;"")&row()));INDIRECT("C"&row()&":"&SUBSTITUTE(ADDRESS(1;MATCH(OFFSET(INDIRECT(ADDRESS(1;COLUMN()));0;-5);$1:$1;0)-1;4);1;"")&row());0));"w");"")

I was wondering: is there an easier/simpler way to do this with google sheets formulas? Basically I want the range to be from C1:<whatever letter is before the Total column>.

Thanks!


Viewing all articles
Browse latest Browse all 9843

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>