Note: The other languages of the website are Google-translated. Back to English

 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


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.


The Best Office Productivity Tools

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. 60-day money back guarantee.
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
Comments (26)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Good one! it worked!
This comment was minimized by the moderator on the site
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?"
This comment was minimized by the moderator on the site
Thank You for posting this!
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
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?
This comment was minimized by the moderator on the site
Use IFERROR(put your function here, "").
This comment was minimized by the moderator on the site
How to return the row number of the second non-blank cell? Coulld you me?
This comment was minimized by the moderator on the site
How can I return the row number of the second non-blank cell? It would help me a lot with my paper.
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
Exactly this question is from my side
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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?
This comment was minimized by the moderator on the site
Doesn't work in Google sheets with Error: Did not find value "2" in lookup evaluation.


Works well in Ms excel.
This comment was minimized by the moderator on the site
Try this in google sheets:


=INDEX( FILTER( F:F , NOT( ISBLANK( F:F ) ) ) , ROWS( FILTER( F:F , NOT( ISBLANK( F:F ) ) ) ) )
This comment was minimized by the moderator on the site
How do I edit the formula to pull the last non-blank cell instead of the first?
This comment was minimized by the moderator on the site
this is what I need too!
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
How To Return The Last Non Blank Cell from some selected cells In A Row
This comment was minimized by the moderator on the site
I would really love to know why ,1/([RANGE]<>0) works :(
This comment was minimized by the moderator on the site
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??
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
It works to find last non blank cell that has more than 255 characters, also. Helpful for me to solve issue.
Thanks a lot !
This comment was minimized by the moderator on the site
Hi
I want to return the first non blank cell in a row but rather that with
information in top cell of the fist nin blank cell.
This comment was minimized by the moderator on the site
Thank you so much for your content! I don't know what I'm doing wrong but I can't seem to be able to do this (in Google sheets) :

I need to fill H1 with the value from the first non-empty cell from C1 to G1. Then I need to copy this for all next rows (H2, H3, H4 etc)

Thanking you in advance for your time, it would be very appreciated :)
This comment was minimized by the moderator on the site
Hi, Marissa,
If you want to get the first non blank value from a row in Google sheets, please apply any one of the following formulas:

=QUERY(transpose(C1:G1),"Select Col1 where Col1 is not null limit 1",0)
=index(C1:G1,MATCH(FALSE,ISBLANK(C1:G1),0))

Please try, hope it can help you!
There are no comments posted here yet
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations