Deduplicate spreadsheet rows keeping latest entry

Finds duplicate records in your data and generates clean formulas or step-by-step instructions to keep only the newest record.

Text prompt for ChatGPT and Claude

You get: Identified Key Columns, modern Formula Method and native Toolbar Method

Prompt

Prompt
Act as an expert spreadsheet analyst. Review the table headers and sample rows pasted below to provide the exact steps to deduplicate rows while preserving the newest record.

Rules:
- Identify which column represents the unique identifier and which represents the timestamp or date.
- Provide an exact formula solution for Excel and Google Sheets using modern functions like SORT and UNIQUE or FILTER.
- Provide a non-formula menu-based fallback method using native sorting and deduplication.
- State clearly what happens if two identical identifiers share the exact same timestamp.

Output format:
1. Identified Key Columns
2. Modern Formula Method (with exact syntax)
3. Native Toolbar Method (numbered steps)
4. Verification Step

My data headers and sample rows are below:

Example output

Example for: user subscription logs with repeated user IDs and update dates

  1. Identified Key Columns
  • Unique Identifier: User ID (Column A)
  • Timestamp: Last Activity Date (Column C)
  • Data Range: A2:D100
  1. Modern Formula Method
    In a new sheet or empty area, place this formula in cell F2:
    =SORT(SORTBY(A2:D100, C2:C100, -1), 1, 1)
    For Excel 365 or Google Sheets with modern dynamic arrays, to extract distinct records based strictly on the newest entry:
    =LET(sorted, SORTBY(A2:D100, C2:C100, -1), ids, INDEX(sorted,,1), FILTER(sorted, MATCH(ids, ids, 0) = SEQUENCE(ROWS(ids))))
  2. Native Toolbar Method
  3. Select your full data table including headers (A1:D100).
  4. Go to the Data tab and click Sort.
  5. Add a primary sort level: 'Last Activity Date', set Order to 'Newest to Oldest'. Click OK.
  6. With the data still selected, click Data > Remove Duplicates.
  7. Uncheck all columns except 'User ID'. Click OK.
    Because Excel preserves the first item it encounters, it keeps the newest row and discards older ones.
  8. Verification Step
    Compare the row count before and after deduplication using =COUNTA(A2:A100) vs =COUNTA(F2:F100). Run =COUNTIF(F2:F50, F2) in an adjacent column to verify all remaining counts equal 1.
Written by AI from this prompt. Your results will vary.

Paste your column names and a few sample rows at the bottom of the prompt in Claude, ChatGPT, or Gemini. As a follow-up, ask how to adapt the formula if your date column uses text strings instead of true dates.

Reuse it: Use in a workflowTurn into a skillAdapt in the builder

Excel & SpreadsheetsGemini

Write Google Sheets REGEX Formulas to Extract and Clean Text

Get ready-to-paste REGEXEXTRACT, REGEXREPLACE, or REGEXMATCH formulas for Google Sheets with a token-by-token breakdown.

Excel & Spreadsheets

Clean phone numbers and postal codes using Excel formulas

Transform irregular contact details into uniform formats for clean CRM imports. Use this whenever raw exports mix dashes, dots, spaces, or leading zeroes.

Excel & Spreadsheets

Consolidate separate spreadsheet tabs into a master rollup

Design a dynamic rollup architecture to aggregate multiple project or regional sheets into one live master summary that will not break when rows expand.

Excel & Spreadsheets

Parse Unstructured Text into Clean Excel Columns

This prompt generates specific Excel formulas to split messy text strings into organized columns while handling edge cases like missing delimiters.

Excel & Spreadsheets

Clean and Standardize Messy Spreadsheet Data with Exact Formulas

Get a column-by-column cleaning plan with ready-to-fill formulas for spaces, case, dates and duplicates, plus a list of rows that need a manual check.

Excel & Spreadsheets

Pick XLOOKUP, VLOOKUP or INDEX MATCH and Get the Exact Formula

You get one recommended lookup method for your Excel version and data layout, a paste-ready formula, and clear handling for values that have no match.