Display the address of the last non-empty cell (if values are not unique)

后端 未结 3 682
南笙
南笙 2021-01-06 23:25

I have the following Excel spreadsheet:

             A                             B       C      D      E       F

1 |                                     |         


        
3条回答
  •  悲&欢浪女
    2021-01-06 23:42

    You can use the following array formula:

    = ADDRESS(ROW(B2),MAX(COLUMN(2:2)*NOT(ISBLANK(2:2))))
    

    This returns the address of the last non-empty cell in the 2nd row.

    Note this is an array formula, so you muse press Ctrl+Shift+Enter on the keyboard when entering this formula rather than just pressing Enter.

    I agree with @ScottCraner that returning the address usually isn't useful. If you are planning on using this value, as part of another formula, you should not do this:

    = INDIRECT(ADDRESS(ROW(B2),MAX(COLUMN(2:2)*NOT(ISBLANK(2:2)))))
    

    Instead, skip using INDIRECT and ADDRESS altogether and instead use INDEX to get the value in that cell, i.e.

    = INDEX(2:2,MAX(COLUMN(2:2)*NOT(ISBLANK(2:2)))))
    

提交回复
热议问题