Get the last non-empty cell in a column in Google Sheets

后端 未结 16 2206
温柔的废话
温柔的废话 2020-11-28 21:04

I use the following function

=DAYS360(A2, A35)

to calculate the difference between two dates in my column. However, the column is ever exp

16条回答
  •  执念已碎
    2020-11-28 21:33

    This will give the contents of the last cell:

    =indirect("A"&max(ARRAYFORMULA(row(a:a)*--(a:a<>""))))
    

    This will give the address of the last cell:

    ="A"&max(ARRAYFORMULA(row(a:a)*--(a:a<>"")))
    

    This will give the row of the last cell:

    =max(ARRAYFORMULA(row(a:a)*--(a:a<>"")))
    

    Maybe you'd prefer a script. This script is way shorter than the huge one posted above by someone else:

    Go to script editor and save this script:

    function getLastRow(range){
      while(range.length>0 && range[range.length-1][0]=='') range.pop();
      return range.length;
    }
    

    One this is done you just need to enter this in a cell:

    =getLastRow(A:A)
    

提交回复
热议问题