Getting Rid of All Rows Except the One for the Latest Date

by Allen Wyatt
(last updated April 25, 2019)


Gary is using an Excel worksheet to maintain of list of facilities that his company inspects, along with the dates of all the prior inspections of those facilities. This results in multiple rows for each facility, one row per inspection. Gary needs to delete all the rows for each facility with the exception of the latest inspection date. The result would be one row per facility, showing the latest inspection date.

Perhaps the easiest way to do this is to use Excel's remove duplicate tool. To use the tool for this particular purpose, follow these steps:

  1. Select a cell within your data.
  2. Display the Data tab of the ribbon.
  3. Click the Sort tool. Excel displays the Sort dialog box.
  4. Using the controls in the dialog box, indicate that you want to sort first by facility (A to Z or Smallest to Largest, whichever is appropriate) and then by inspection date (Newest to Oldest). (See Figure 1.)
  5. Figure 1. The Sort dialog box.

  6. Click OK to actually sort the data.
  7. With the Data tab of the ribbon still visible, click the Remove Duplicates tool in the Data Tools group. Excel displays the Remove Duplicates dialog box.
  8. Make sure that the only field selected in the dialog box is the one that contains the facility. (See Figure 2.)
  9. Figure 2. The Remove Duplicates dialog box.

  10. Click OK. Excel removes the duplicates and leaves only those records that contain the latest (most recent) inspection date.

Understand that if you follow these steps it is destructive to your data—when completed, the older data is completely removed from your worksheet. Thus, if you want to maintain the older information for historical purposes, you may want to perform the steps on a duplicate of your data.

Of course, you could also use a different approach that maintains the original data and simply extracts the information that represents the latest inspection dates. Assume, for the purposes of this example, that your data is in columns A:C, with A containing the facility, B containing the inspection date, and C containing the rating achieved on that date. Further, the first row of your data contains headings (Facility, Inspected, and Rating). Somewhere to the right of your data—separated by at least one empty column—place another set of identical headings. (For this example I'll assume that these appear columns E:G.)

In the first column place a unique list of your facilities. In cell F2 place the following formula:


You can replace the two lower range references ($A$123 and $B$123) with whatever lower range is appropriate for your data. Also, you need to enter this as an array formula, meaning you press Ctrl+Shift+Enter to add it to cell F2.

The result in cell F2 will be a number, which is actually a date. (Excel maintains dates internally as numbers.) To get F2 to look like a date, simply apply a date format to the cell.

In cell G2 place the following formula:


Again, the lower range references can be replaced with whatever reference is appropriate for your data. This is not an array formula, so you can simply press Enter to put it in cell G2.

Now copy cells F2:G2 down as many rows as appropriate for your facilities. What you end up with is a dynamic list of the most recent inspection results for each facility. (See Figure 3.)

Figure 3. A dynamic list of the latest inspection results.

As you add more data to your inspection list, your "result table" is updated to always show the latest inspection results.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13125) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...


Copying Red Text to a New Document

Need to copy all the red text in your document to a different document? There are several ways you can approach the task; ...

Discover More

Personal.xls File Not Opening

The Personal.xls workbook is used primarily to store macros that you want available through all of your workbooks. ...

Discover More

Opening a Workbook but Disabling Macros

Macros that run automatically when you open or close a workbook are quite helpful. You may not want them to run, however, ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Inserting Different Dashes

Excel supports several types of dashes. This tip describes those different types and explains how to enter them in a cell.

Discover More

Uncovering and Removing Links

Excel allows you to reference data in other workbooks by establishing links to that data. If you later want to get rid of ...

Discover More

Displaying Row and Column Labels

When you create a worksheet, it is common to place headings at the top of each column and the left of each row so you can ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 + 7?

2019-03-05 12:49:27


I'm looking to do the same, but I have no date column. My latest are the last entry's. How would I delete all the duplicates except for the last entry then?

2017-02-07 10:38:38


What if Rating in some cells is missing and I want to print the next most recent rating? in my data, column A is employee Id, B is the performance rating and 3rd is actual rating. Emp Id appears two three or sometimes five times making up groups, column b has all the dates filled in but the rating column isn't completely filled in. I'd really appreciate the workaround to get the most recent date for which there is a rating in column C.. thank you!

2016-12-14 09:51:06


In Ken's solution using the formula in column D to filter the list, if you compare two COUNTIF statements, down to the current row and for the whole list, on the facility, it will filter on a growing list of inspections added to the end of the list as they happen without the need to sort it each time by facility and date. If the two COUNTIF statements have the same result that will be the last entry for that facility in the list and therefore the latest, if they are different the line can be filtered out.

2016-12-14 07:17:30

frank mccraw

I believe most analysts who read this post would blanch at the idea of destroying historical data, which would otherwise permit time series analysis of each facility from within a single spreadsheet database. The "extract" and "dynamic" display options are far superior to any "delete previous" data methods, as Allen Wyatt hints.

2014-06-02 03:12:47


Another idea that also keeps all the data, is to have in column 'D' a formula that detects when the facility value changes.
Assuming once again that the sorting has been done as suggested above, (by facility the most recent at the top) then in column 'D' starting at D2 do an IF formula like IF(A2=A1,"SAME","DIFF") and copy that down ... which means that whenever the facility value in this row is different to the facility in the row above you get "DIFF" in column 'D' ... then just filter on column 'D' for those rows that have the word "DIFF" in them.

This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.