How to Auto Alphabetize in Google Sheets Automatically

How-to basics · Updated November 3, 2026

How to Auto Alphabetize in Google Sheets Automatically

To keep a Google Sheets list alphabetized, use a SORT formula for a live, sorted copy, or an Apps Script that re-sorts the original list after you edit it. For a one-time sort, select the data and choose Data > Sort range. Before sorting, make sure each row’s related information is included so names stay paired with their details.

Google Sheets does not have a built-in switch that continuously sorts an editable list as you type. The best method depends on whether you want to preserve the original order, automatically rearrange the source rows, or just sort the list once. The steps below cover all three.

What You’ll Need

  • A Google account and a spreadsheet open in Google Sheets in a web browser.
  • A list with a clear header row, if it has one, and a column to use as the alphabetizing key, such as names in column A.
  • For the automatic source-sorting option, permission to edit the spreadsheet and access Extensions > Apps Script.

If your list has related details—such as a name in column A and an email address in column B—treat each complete row as one record. Sort the full table by the name column, not just the cells containing names.

Step-by-Step

  1. Choose what “auto alphabetize” should mean for your sheet. Use the menu sort if you only need to organize the list now. Use a formula if you want a separate view that updates when the source changes but do not want the original rows rearranged. Use Apps Script if you want edits to trigger sorting of the original data. Decide before proceeding: sorting the source and displaying a sorted copy are different workflows.
  2. Check the layout before sorting. Put column labels in the first row, for example, Name in A1 and Email in B1, with records beginning in row 2. Keep each record on a single row and avoid merged cells in the data area. If there are other fields, include their columns in the table range so they move with the name. Make a copy first if the current order matters.
  3. For a one-time sort, select the whole data range. Drag across all columns and rows that belong to the table, including the header row. Then choose Data > Sort range > Advanced range sorting options. In the dialog, check “Data has header row” if the first selected row contains labels. Choose the name column under “Sort by,” select A to Z, and click Sort. For a table without a header, select only the records and leave the header option unchecked.
  4. For a live sorted copy, leave the source list in place. Choose an empty area or a new sheet where the results can expand. With names in A2:A100 and a related field in B2:B100, enter =SORT(A2:B100,1,TRUE) in the top-left destination cell. The formula sorts the rows by the first column of the selected range in ascending order. Keep the output cells clear; a formula result needs room to expand and otherwise may show an error.
  5. Make the formula cover future entries. The example ends at row 100, so it will not include a record entered below that row. Increase the range to a sensible limit, such as A2:B500, or adjust it as your list grows. If your source contains blank rows, a simple SORT may show blank results in the sorted output. To omit rows with no name, and when your source is in A2:B500, use =SORT(FILTER(A2:B500,A2:A500<>""),1,TRUE). Enter this only where the result area is empty. Formula separators can vary with spreadsheet locale; if commas are rejected, check the locale’s expected separator.
  6. For automatic sorting of the original rows, open Apps Script. Choose Extensions > Apps Script. In the editor, replace any sample code in the script file with the code below. This example assumes the sheet tab is named List, row 1 is a header, and the table consists of columns A and B. It sorts A to Z after a user edits either table column.
  7. Save the script and test it carefully. Click Save project, return to the spreadsheet, and make a small change to a data cell in column A or B. After the edit, the row should move into its alphabetical position while its A and B values stay together. A simple onEdit trigger runs for direct user edits; it does not run when a formula’s result changes. If the script asks for authorization or reports an error, review the troubleshooting section below.
function onEdit(e) {
  const sheet = e.range.getSheet();

  // Run only on the List tab and ignore the header row.
  if (sheet.getName() !== 'List' || e.range.getRow() < 2) return;

  // This example uses columns A and B as the complete table.
  if (e.range.getColumn() > 2) return;

  const lastRow = sheet.getLastRow();
  if (lastRow < 2) return;

  // Sort all data rows by the first column, keeping A and B together.
  sheet.getRange(2, 1, lastRow - 1, 2)
    .sort({ column: 1, ascending: true });
}

The Apps Script range is deliberately limited to two columns. If your records continue through column D, change the final width argument from 2 to 4 so the entire row moves as a unit. If the sheet contains other information outside the table, do not expand the range to include it accidentally. Change List to the exact tab name, including spaces and capitalization. Save changes in the script editor before testing.

Common Mistakes

  • Sorting only the name column. If other columns hold the same record’s information, sorting only column A can mismatch names and emails, dates, or other details. Select the full table for a manual sort, use the full table range in SORT, or make the script sort the complete row width.
  • Including a header as a record. In a manual sort, mark the header-row option. In a formula or script, begin with row 2 when row 1 contains labels. Otherwise, the label may be sorted among the names.
  • Expecting a formula to rearrange its source cells. SORT returns a sorted result in a different location. It does not reorder the original range. Use Apps Script or a manual sort when you specifically need the source itself to change order.
  • Typing into the formula’s output area. A live array result cannot expand over cells that already contain values. Place the formula in a clear area and remove any blocking contents if the result reports that it could not expand.
  • Assuming every edit triggers Apps Script. The sample responds to direct edits in columns A and B, not edits elsewhere or changes produced solely by recalculating a formula. Its simple trigger also sorts after an edit, so the row you just changed may move immediately.
  • Leaving out part of a record in the script range. The sample sorts A:B only. If the record extends into C or later columns, those values will not move with the row unless you widen the range. Test on a copy if you are unsure.

Tips

  • Keep a stable key column. Put the value you want to sort by—such as last name or company—in its own column. If you sort by a full name, the order will be based on the text in that cell, typically beginning with the first name.
  • Choose the right range for a growing list. A formula with a fixed endpoint is easy to understand but must be expanded when the list grows. Pick a realistic capacity and check it periodically. Keep the destination area free for the returned rows.
  • Use a separate output tab for formula results. A separate tab helps distinguish the original input order from the sorted display and reduces the chance of typing over formula output. Add clear column labels above the formula result if useful.
  • Consider locale and spelling conventions. The spreadsheet’s locale can affect how accented characters and some text are ordered. If a particular language’s alphabet or a custom order is important, inspect the result rather than assuming every locale sorts identically.
  • Make the automatic script narrow and predictable. Restrict it to the intended tab and columns, keep the header out of its sort range, and avoid editing unrelated data inside that range. A narrowly scoped trigger is less likely to move other content by mistake.
  • Keep a recoverable copy. Before setting up an automatic sort on a busy or important sheet, duplicate the tab or spreadsheet. Sorting changes row positions, which can surprise collaborators who rely on the current order.

Troubleshooting

The order does not change after I edit. Confirm that the tab name in the script exactly matches the sheet tab, that the edit is in a data row, and that the edited column is included in the script’s allowed columns. The example ignores row 1 and columns after B. Also check that the script was saved and that you edited the sheet directly; formula recalculation and some automated updates do not fire a simple on-edit trigger.

The script displays an error or appears not to run. Reopen Extensions > Apps Script and check the execution details for the latest run. Confirm that the code was pasted as shown, that the table range exists, and that the script is attached to the spreadsheet you are editing. A protected range or insufficient edit permission can prevent changes. Simple triggers are intended for lightweight actions in their bound spreadsheet; if you replace this with a more complex script that uses services requiring authorization, you may need to set up an installable trigger and grant the requested permissions.

The names sort, but their details no longer match. Undo the sort immediately if possible, or restore a prior version from File > Version history > See version history. Then repeat the sort using the complete table. For Apps Script, widen the range so every field belonging to each record is included. A formula also needs all associated columns in its input range, as in A2:B100, rather than just A2:A100.

The formula shows an expansion or reference error. Clear cells below and beside the formula where its results need to appear, and verify that the source range is valid. If using FILTER, ensure the criteria range has the same number of rows as the data range. If the formula parser rejects commas, check the spreadsheet locale and use the separator expected by that locale. A formula that returns no matching rows may also need a separate empty-list message or a different setup.

Some entries seem out of place. Check for leading spaces, inconsistent spelling, numbers stored as text, or extra characters. Use consistent text values in the sort column. If the order depends on a specific language’s collation, review the spreadsheet locale and test representative accented names in a small sample.

Frequently Asked Questions

Can Google Sheets alphabetize a list automatically as I type?
Not with a built-in always-sort toggle. A SORT formula keeps a separate displayed copy ordered as its source changes. Apps Script can sort the original rows after qualifying direct edits, but it needs setup and should be tested with your table layout.

Does the SORT formula change my original list?
No. It produces sorted results in the cell where you enter the formula and the cells below or beside it. The original data stays in its existing order unless you use a menu sort or a script that sorts the source range.

How do I keep names and email addresses together?
Sort the entire table, using the name column as the sort key. For a formula, include both columns in the input range. For the sample script, set the range width to include every column in each record.

Can I sort Z to A instead?
Yes. In the sort dialog, choose Z to A. In a SORT formula, change the final argument from TRUE to FALSE, for example =SORT(A2:B100,1,FALSE). In the Apps Script sort specification, change ascending: true to ascending: false.

Will the Apps Script sort when a formula changes a name?
No. A simple onEdit trigger responds to direct user edits, not ordinary formula recalculation. If the key value is generated by a formula, a live SORT formula may be a better fit, or the script may need a different trigger design.

Is this different in Excel?
Yes. These menu paths, Google Sheets formulas, and Apps Script instructions are for Google Sheets in a web browser. Excel has its own sorting tools and automation options, so do not expect the Apps Script steps to apply there.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.