Find the last non empty cell ADDRESS without VBA

帅比萌擦擦* 提交于 2020-01-04 03:51:17

问题


I need to find the last non empty cell in an Excel spreadsheet, but I need its address, not its value.

For example: When I want the value for the last non empty cell in column K, I use this formula:

=LOOKUP(2;1/(NOT(ISBLANK(K:K)));K:K)

My problem is, I dont want cell's value, I need its address instead.

I already tried to use function CELL without success.


回答1:


You can get the last populated row number of a known column with the MATCH function but it helps to know whether the column is filled with numbers and/or dates or text.

=match("zzz"; K:K)   'for last text¹ in column K
=match(1e99; K:K)    'for last date or number in column K

The ADDRESS function returns the rest.

=address(match("zzz"; K:K); 11; 4; 1)  'address of last text¹ in column K
=address(match(1e99; K:K); 11; 4; 1)   'address of last date or number in column K
=address(max(iferror(match(1e99; K:K); 0); iferror(match("zzz"; K:K); 0)); 11; 4; 1)   'address of last date or number or text¹ in column K

The 4 is for relative addressing (e.g. K99); the 1 is for xlA1 addressing. See the provided link for full syntax on the ADDRESS function.


¹ Note that a 'zero-length string' (e.g. "" ) like that typically returned by an error controlled MATCH or VLOOKUP is considered a text value, not a blank or null value.



来源:https://stackoverflow.com/questions/38268333/find-the-last-non-empty-cell-address-without-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!