Selecting the last value of a column

前端 未结 23 1790
再見小時候
再見小時候 2020-11-28 19:15

I have a spreadsheet with some values in column G. Some cells are empty in between, and I need to get the last value from that column into another cell.

Something li

相关标签:
23条回答
  • 2020-11-28 19:44

    This gets the last value and handles empty values:

    =INDEX(  FILTER( H:H ; NOT(ISBLANK(H:H))) ; ROWS( FILTER( H:H ; NOT(ISBLANK(H:H)) ) ) )
    
    0 讨论(0)
  • 2020-11-28 19:45

    In order to return the last value from a column of text values you need to use COUNTA, so you would need this formula:

    =INDEX(G2:G; COUNTA(G2:G))
    
    0 讨论(0)
  • 2020-11-28 19:48

    Actually I found a simpler solution here:

    http://www.google.com/support/forum/p/Google+Docs/thread?tid=20f1741a2e663bca&hl=en

    It looks like this:

    =FILTER( A10:A100 , ROW(A10:A100) =MAX( FILTER( ArrayFormula(ROW(A10:A100)) , NOT(ISBLANK(A10:A100)))))
    
    0 讨论(0)
  • 2020-11-28 19:51

    Regarding @Jon_Schneider's comment, if the column has blank cells just use COUNTA()

    =INDEX(G2:G; COUNT**A**(G2:G))
    
    0 讨论(0)
  • 2020-11-28 19:52

    Is it acceptable to answer the original question with a strictly off topic answer:) You can write a formula in the spreadsheet to do this. Ugly perhaps? but effective in the normal operating of a spreadsheet.

    =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
    

    This is offered as a thought for a range of questions in the script area that could be delivered reliably with array formulas which have the advantage of often working in similar fashion in excel and openoffice.

    0 讨论(0)
提交回复
热议问题