## 選擇列的最後一個值 (14)

``````=LAST(G2:G9999)
``````

## 概要：

``````=INDEX( FILTER( G2:G , NOT(ISBLANK(G2:G))) , COUNTA(G2:G) )
``````

## 細節：

``````=INDEX(G2:G; COUNT(G2:G))
``````

``````=INDEX(G2:G; COUNTA(G2:G))
``````

``````=INDEX( FILTER( G2:G , NOT(ISBLANK(G2:G))) , ROWS( FILTER( G2:G , NOT(ISBLANK(G2:G)) ) ) )
``````

``````=INDEX( FILTER( G2:G , NOT(ISBLANK(G2:G))) , COUNT( FILTER( G2:G , NOT(ISBLANK(G2:G)) ) ) )
``````

``````=INDEX( FILTER( G2:G , NOT(ISBLANK(G2:G))) , COUNTA(G2:G) )
``````

``````=INDEX( FILTER( A2:2 , NOT(ISBLANK(A2:2))) , COUNTA(A2:2) )
``````

``````// Returns row number with the last non-blank value in a column, or the first row
//   number if all are blank.
// Example: =rowWithLastValue(a2:a, 2)
// Arguments
//   firstRow: Row number of first row. It would be nice to pull this out of
//     the range parameter, but the information is not available.
function rowWithLastValue(range, firstRow) {
// range is passed as an array of values from the indicated spreadsheet cells.
for (var i = range.length - 1;  i >= 0;  -- i) {
if (range[i] != "")  return i + firstRow;
}
return firstRow;
}
``````

``````=+sort(G:G,row(G:G)*(G:G<>""),)
``````

``````=ARRAYFORMULA(LOOKUP(2,1/(G2:G<>""),G2:G))
``````

`G2:G<>""`創建1 / true（1）和1 / false（0）的數組。 由於`LOOKUP`使用自頂向下的方法來查找`2`並且因為它永遠不會找到2，所以它會出現在最後一個非空白行並給出了它的位置。

``````=INDEX(G2:G,MAX((ISBLANK(G2:G)-1)*-ROW(G2:G))-1)
``````

V18

``````=INDIRECT("R[-"&COUNTBLANK(V4:V17)+1&"]C",0)
``````

``````function lastValue(myRange) {
lastRow = myRange.length;
for (; myRange[lastRow - 1] == "" && lastRow > 0; lastRow--)
{ /*nothing to do*/ }
return myRange[lastRow - 1];
}
``````

``````= lastValue(E17:E999)
``````

``````=INDEX(G2:G; COUNTA(G2:G))
``````

``````=indirect("R"&ArrayFormula(max((G:G<>"")*row(G:G)))&"C"&7)

(G:G<>"") gives an array of true false values representing non-empty/empty cells
(G:G<>"")*row(G:G) gives an array of row numbers with zeros where cell is empty
max((G:G<>"")*row(G:G)) is the last non-empty cell in G
``````

``````\$ =INDEX(G2:G; COUNT(G2:G))
``````

``````\$ =INDEX(G2:G100000; COUNT(G2:G100000))
``````

``````=INDEX(G2:G, COUNT(G2:G))
``````

``````=INDEX(I:I;MAX((I:I<>"")*(ROW(I:I))))
``````

``````=INDEX(  FILTER( H:H ; NOT(ISBLANK(H:H))) ; ROWS( FILTER( H:H ; NOT(ISBLANK(H:H)) ) ) )
``````

``````function getDashboardSheet(spreadsheet) {
var sheetName = 'Name';
}
``````function lastRow(column){