Remove duplicate rows from a sheet

Keeps the first copy of each identical row in the active sheet.

function removeDuplicates() {
  const sheet = SpreadsheetApp.getActiveSheet();
  const range = sheet.getDataRange();
  range.removeDuplicates();
}

How to install

  1. Open the spreadsheet, then Extensions > Apps Script.
  2. Paste the code, click Save.
  3. Choose the function in the toolbar and click Run once; approve the permissions screen (it lists exactly what the script can touch).
Safety: Uses the built-in Range.removeDuplicates(); make a copy of the tab first.

Undo: Edit > Undo, or restore from File > Version history.

Reference: Apps Script documentation.

Facts on this page checked December 4, 2026 (Pacific) against the linked official sources.