Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

 How to return the first / last non blank cell in a row or column?

When you work with a worksheet, sometimes, you may want to get the first or last non blank cell value of a row or column. It is easy for you to get the value if there are few data in a row or column at a glance, but to return the data in a long column or row will be a painful task. Here, I can talk you about some useful methods to solve this job.

Return the first non blank cell in a row or column with formula

Return the last non blank cell in a row or column with formula


Combine multiple worksheets, workbooks and csv files into one worksheet / workbook:
In your daily work, to combine multiple worksheets or workbooks into one single worksheet or workbook may be a huge and headachy work. But, if you have Kutools for Excel, with its powerful utility – Combine, you can quickly combine multiple worksheets, workbooks into one worksheet or workbook.
doc combine multiple worksheets-1

arrow blue right bubble Return the first non blank cell in a row or column with formula


To extract the first cell with data, please apply the following formula:

1. Enter the following formula into a blank cell besides your data: =INDEX(A1:A13,MATCH(TRUE,INDEX((A1:A13<>0),0),0)), see screenshot:

doc-return-first-data-cell-1

2. Then press Enter key, and you will get the first non blank cell value as follows:

doc-return-first-data-cell-1

Notes:

1. In the above formula, A1:A13 is the column range that you want to use, you can change it to your need. This formula also can be applied to get the first non blank cell value in a row, you just need to change the column range to row range.

2. This formula just work correctly on single row or single column.


arrow blue right bubble Return the last non blank cell in a row or column with formula

If you want to return the last non blank cell value, here is another formula can do you a favor.

1. Type this formula =LOOKUP(2,1/(A1:A13<>""),A1:A13) into a blank cell besides your data, see screenshot:

doc-return-first-data-cell-1

2. Then press Enter key, the last non blank cell value will be extracted at once. See screenshot:

doc-return-first-data-cell-1

Notes:

1. In the above formula, A1:A13 is the column range that you want to use, you can change it to your need. This formula also can be applied to get the last non blank cell value in a row, you just need to change the column range to row range.

2. The above formula just work correctly on single row or single column.


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Guest · 8 months ago
    A1:A13<>0 returns an array of value that are either true or false
    all values that are not 0 (eg <>0) in A1:A13 become true, and all else become false
    So now you can look up the first 'true' in that array and use it to index
  • To post as a guest, your comment is unpublished.
    Matt · 8 months ago
    What does "INDEX((A1:A13<>0)" mean? The first parameter to INDEX is the set of cells A1 through A13 but with a test for not equal to zero appended. I can't find any explanation of this.
  • To post as a guest, your comment is unpublished.
    guest · 9 months ago
    Hi can someone helpme on this,

    I have a csv file or maybe a excel which has n number of data's in it from which i need few collective data's using formulas which should be automatic,and i need the output to be in a table form.can please anyone helpme on this??
  • To post as a guest, your comment is unpublished.
    RaRdEvA · 10 months ago
    I would really love to know why ,1/([RANGE]<>0) works :(
  • To post as a guest, your comment is unpublished.
    Taufiq · 1 years ago
    How To Return The Last Non Blank Cell from some selected cells In A Row
  • To post as a guest, your comment is unpublished.
    Muhd Aiman · 1 years ago
    Doesn't work in Google sheets with Error: Did not find value "2" in lookup evaluation.


    Works well in Ms excel.
    • To post as a guest, your comment is unpublished.
      Ankur · 1 years ago
      Try this in google sheets:


      =INDEX( FILTER( F:F , NOT( ISBLANK( F:F ) ) ) , ROWS( FILTER( F:F , NOT( ISBLANK( F:F ) ) ) ) )
      • To post as a guest, your comment is unpublished.
        amgosto · 11 months ago
        How do I edit the formula to pull the last non-blank cell instead of the first?
        • To post as a guest, your comment is unpublished.
          Keris · 10 months ago
          this is what I need too!
          • To post as a guest, your comment is unpublished.
            MrFrizzy · 2 months ago
            The formula that Ankur posted does return the value of the last non-blank cell in the specified range (column). If you are looking to make this work across columns on a single row, then change "ROWS" to "COLUMNS" within the formula.
  • To post as a guest, your comment is unpublished.
    Claus Adelmann · 1 years ago
    Hi thanks for the formula. How can I extend this formula if I have a table A-N and need to lookup certain value in A first to locate row in which I want to get as a result last non blank value found in column H-L?
  • To post as a guest, your comment is unpublished.
    Sunil Kerody · 1 years ago
    Hi, thanks for the The Last Non Blank Cell In A Row Or Column formula, this is want I was exactly looking for,
    Can you please explain me the logic? (why for lookup_vector vale you have passed 1/(range<>=””))
    Regards,
    SK
  • To post as a guest, your comment is unpublished.
    SK · 1 years ago
    Hi, Thanks for the formula (Return The Last Non Blank Cell In A Row Or Column With Formula - =LOOKUP(2,1/(A1:A13<>""),A1:A13))
    This formula did what i was exactly looking for. just for my understanding, can you please explain the logic?, why 2 is used for lookup value and logic of lookup_vector in formula.
    Thanks in advance

    Regards,
    SK
  • To post as a guest, your comment is unpublished.
    Juan Miguel · 1 years ago
    How can I return the row number of the second non-blank cell? It would help me a lot with my paper.
  • To post as a guest, your comment is unpublished.
    Alliage · 1 years ago
    How to return the row number of the second non-blank cell? Coulld you me?
  • To post as a guest, your comment is unpublished.
    Hassan · 1 years ago
    I need help to get a data from collumn A.
    In Row-1 I've a lot of name. From these I need to look up a name,find out last non zero value of that name column and then find the respected data from Collumn A.

    Can you guyz please help??

    I don't know how to add pictures here.





    • To post as a guest, your comment is unpublished.
      Ken J · 1 years ago
      Use IFERROR(put your function here, "").
    • To post as a guest, your comment is unpublished.
      SGB · 1 years ago
      hi, if the row that you are looking for content is completely empty, it is returning "#N/A". How can I get it to return nothing and leave the cell blank?
  • To post as a guest, your comment is unpublished.
    Me · 2 years ago
    Thank You for posting this!
  • To post as a guest, your comment is unpublished.
    Bob Hungerschafer · 4 years ago
    Using values in a8,b8,c8: 0 8 A8
    Copying this formula to the next to cells on the right
    =ROW(INDEX(A1:A100,MATCH(TRUE,INDEX((A1:A1000),0),0)))
    Yields: 9 8 8

    However copying this formula to the next to cells on the right
    =ROW(INDEX(A1:A100,MATCH(TRUE,INDEX((A1:A100""),0),0)))
    Yields: 8 8 8

    1st non zero is not the same as 1st non blank ergo the 2nd formula yields what was stated in the premise statement: "How to return the first / last non blank cell in a row or column?"
  • To post as a guest, your comment is unpublished.
    ManU · 4 years ago
    Good one! it worked!