How I can get column name of last non zero value in row, using Excel functions.
Example:
A:E - columns with values x - function result
A B C D E x
0 0 1 0 0 C
1 0 2 1 2 E
0 1 1 0 1 E
1 1 1 1 1 E
0 0 0 0 0
These are array-formulas that must be entered using CTRL
+ SHIFT
+ ENTER
:
This works up to ZZ:
=IFERROR(SUBSTITUTE(MID(CELL("address",OFFSET(A1,0,MAX(IF(A1:AA1<>0,COLUMN(A1:AA1),0))-1)),2,2),"$",""),"")
This works for all columns:
=IFERROR(MID(CELL("address",OFFSET(A1,0,MAX(IF(A1:AAA1<>0,COLUMN(A1:AAA1),0))-1)),2,FIND("$",MID(CELL("address",OFFSET(A1,0,MAX(IF(A1:AAA1<>0,COLUMN(A1:AAA1),0))-1)),2,99))-1),"")
Update: The accepted answer is more efficient. It assumes numeric values but could be easily updated to handle non-numeric values as well. However it could be optimised further:
=IFERROR(MID(SUBSTITUTE(ADDRESS(1,MAX(IF(A2:XED2,COLUMN(A2:XED2)))),"$1",""),2,3),"")
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.