To AutoFit in Excel, select the columns or rows, then choose Home > Cells > Format > AutoFit Column Width (or AutoFit Row Height), or double-click the boundary next to the column or row heading. On Windows the keyboard version is Alt, H, O, I for columns and Alt, H, O, A for rows. Practice with the free Excel practice test on PracticeTestGeeks (500+ questions with answer explanations).
AutoFit tells Excel to size each column or row to its longest or tallest visible content, which fixes #### in number cells and clipped text. This guide covers every method, the Microsoft-documented size limits, why AutoFit sometimes does nothing (merged cells, wrap text, PivotTables), and a macro for one-click formatting across a workbook. Platform differences for Mac and Excel for the web are flagged along the way.
Interactive Excel resources on PracticeTestGeeks, free to start:
AutoFit measures the widest piece of content in a column (or the tallest item in a row) and snaps the boundary to match. It uses the font, font size, and cell formatting in effect when you run it. Change the font from Calibri 11 to Arial 14 later and the column may look cramped again until you re-run AutoFit.
One subtle point. AutoFit Column Width does not shrink a column to honor wrapped lines, so a long wrapped paragraph can leave the column far wider than you want. When a cell holds wrapped text, set the column width yourself first, then run AutoFit Row Height so the row grows to show every line.
Rows behave differently: AutoFit Row Height takes wrapped content into account. The order matters: set the column width first, then AutoFit the row height.
Click the Select All button (the triangle above row 1 and left of column A), then double-click the boundary between any two column headings. Microsoft documents this as the quickest way to AutoFit every column on the worksheet. Double-clicking the boundary below a row heading does the same for every row. On Windows, Ctrl + A selects the whole sheet only when the active cell is outside a data block; press it twice inside data.
You can AutoFit from the mouse, the ribbon, the keyboard, or VBA. Dragging or double-clicking is fastest when your hand is already on the mouse. The ribbon is friendliest for new users, keyboard Key Tips pay off when you AutoFit often, and VBA wins for repetitive reports.
The ribbon command lives under Home > Cells > Format. Under Cell Size you will see Row Height, AutoFit Row Height, Column Width, AutoFit Column Width, and Default Width. The right-click menu on a header offers Column Width or Row Height, but Microsoft does not list AutoFit there, so use the ribbon or the boundary double-click. You can add the Format command to the Quick Access Toolbar if you use it constantly.
| Method | Steps | Where it applies | Notes |
|---|---|---|---|
| Double-click column boundary | Select the column(s), then double-click the boundary to the right of a selected column heading | Microsoft 365, 2024, 2021, 2019, 2016 (Windows article) | Fits the widest visible value; with Select All it fits every column |
| Double-click row boundary | Select the row(s), then double-click the boundary below a row heading | Same as above | Fits the tallest content in the row |
| Ribbon: AutoFit Column Width | Select columns, Home > Cells > Format > Cell Size > AutoFit Column Width | Same as above | Column width range is 0 to 255 characters; default 8.43 |
| Ribbon: AutoFit Row Height | Select rows, Home > Cells > Format > Cell Size > AutoFit Row Height | Same as above | Row height range is 0 to 409 points; default 15.00 |
| Select All + double-click | Click Select All, then double-click any column (or row) boundary | Same as above | Microsoft's documented shortcut for the whole worksheet |
| Keyboard Key Tips | Alt, H, O, I (column width); Alt, H, O, A (row height); press keys one after another | Windows only; the Alt Key Tips do not exist on Mac | Letters follow the ribbon path Home > Format; the on-screen Key Tips confirm them |
| VBA | Cells.EntireColumn.AutoFit and Cells.EntireRow.AutoFit | Desktop Excel with macros enabled; macros do not run in Excel for the web | Save as .xlsm; see the macro section below |
Merged cells are the main exception: AutoFit does not use merged cells to calculate width or height.
Hover the right edge of a column header until the cursor becomes a double arrow, then double-click. Instantly AutoFits that column.
Home > Cells > Format > Cell Size > AutoFit Column Width (or AutoFit Row Height). Works on whatever columns or rows are currently selected.
Windows: Alt, H, O, I for column width and Alt, H, O, A for row height. Press the keys one after another, not together.
Click Select All, then double-click any column boundary. Microsoft documents this as the way to AutoFit every column on the worksheet.
Cells.EntireColumn.AutoFit and Cells.EntireRow.AutoFit. Attach to a button or run on workbook open.
Open the worksheet. Click a column letter to select one column, or drag across several headings. To select every column, click the Select All triangle above row 1 and left of column A.
Go to the Home tab, open Format in the Cells group, and under Cell Size choose AutoFit Column Width. Excel resizes each selected column to its longest visible value.
Prefer the keyboard on Windows? Press Alt, then H, then O, then I, one key at a time. The Key Tip letters appear on the ribbon as you go, which helps if you forget the sequence.
For the mouse, select the column and double-click the boundary to the right of its heading. The cursor turns into a double-headed arrow, and the column snaps to the width of its widest value. Select All first to do every column at once.
Home > Format > AutoFit Column Width. On Windows the Key Tip sequence Alt, H, O, I follows the same path. You can also press Alt + Q and type AutoFit to find the command.
Microsoft's column-width article lists Excel 2016 and 2019 as using the same Home > Cells > Format > AutoFit Column Width steps and the same boundary double-click.
The Alt-key sequences are Windows Key Tips and do not apply on macOS. Select the columns and double-click the boundary to the right of a heading, or use the Format commands in Excel; Microsoft documents Mac steps in a separate "Change the column width or row height (Mac)" article.
Microsoft documents Excel for the web in a separate "Change the column width or row height (web)" article, so check it for the exact menu. VBA macros do not run in the browser, so use the desktop app for macro-based AutoFit.
Row AutoFit is the partner to column AutoFit and matters most when Wrap Text is on. Select the row numbers, then go to Home > Cells > Format and, under Cell Size, choose AutoFit Row Height. Excel grows or shrinks each selected row to its tallest content.
On Windows the keyboard route is Alt, H, O, A. The double-click trick also works: double-click the boundary below a row heading. Select All first to AutoFit every row at once.
Running AutoFit Row Height on a row you previously dragged to a custom height puts the row back under automatic sizing. If the row still shows one line, check that Wrap Text is on (Home > Wrap Text), and that the cell is not part of a merged range, which AutoFit ignores.
If you build the same report every week, manual AutoFit gets old. A two-line macro fixes that forever. Press Alt + F11 to open the Visual Basic Editor. Insert a new module via Insert > Module. Paste the following:
Sub AutoFitEverything()
Cells.EntireColumn.AutoFit
Cells.EntireRow.AutoFit
End SubClose the editor. Press Alt + F8, select AutoFitEverything, click Run. Every column and row in the active sheet snaps to fit. Save the workbook as .xlsm to keep the macro. For a button, go to the Developer tab, click Insert, choose a Form Control button, draw it on the sheet, and assign the macro. One click and the entire sheet is formatted.
Want it across every sheet in a workbook? Wrap the macro in a loop:
Sub AutoFitAllSheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Cells.EntireColumn.AutoFit
ws.Cells.EntireRow.AutoFit
Next ws
End SubThis iterates every worksheet in the file. Perfect for a workbook with a tab for each month or region. Combine with the Workbook_BeforeSave event in ThisWorkbook to AutoFit automatically every time the file saves. Just remember that the macro skips hidden sheets only if you add an If ws.Visible Then check, otherwise it touches them too.
AutoFit interacts with wrap, merges, PivotTables, and query-loaded tables in ways that can trip new users. These are the issues that come up most and the fix for each.
Excel caps column width at 255 characters (Microsoft's documented maximum). If one cell holds a 300-character paragraph, AutoFit hits that ceiling. Turn on Wrap Text for the cell, set a sensible width, then AutoFit Row Height to see all of it. If strings are consistently long, split them with Text to Columns.
Either Wrap Text is off, or the cell is part of a merged range. Turn on Home > Wrap Text, unmerge if needed, then run Home > Format > AutoFit Row Height again. Row height is capped at 409 points, so extremely long wrapped text will still be cut off.
A table loaded from a query or external data can re-size columns when it refreshes. Run AutoFit again after the refresh, or run the macro below at the end of your refresh routine.
Right-click anywhere in the PivotTable, choose PivotTable Options, and on the Layout & Format tab uncheck Autofit column widths on update. Your widths then stay put after a refresh.
AutoFit is brilliant for working sheets, exploratory analysis, and any spreadsheet you build once and discard. The moment you start sharing files with non-technical users, the calculus changes. A column that AutoFits to fit the longest cell will move every time the underlying data changes. That can break printed layouts, mess with dashboards, and surprise readers who expect stable column widths.
For a polished dashboard or template, set widths manually after you AutoFit once. Round each column to a sensible round number (12, 15, 20 characters) and lock the column widths so Excel does not adjust them on refresh. PivotTables have an explicit setting for this, as we saw. For regular ranges, just resist the urge to run AutoFit on a finished design. A good rule: AutoFit early, lock late.
On the other hand, never hand-tune widths for an exported CSV report or an internal QA sheet. AutoFit it and move on. The five seconds you save compound across the year.
One small gotcha: On-screen column widths can differ slightly from what prints. After AutoFit, switch to Page Layout view (View > Page Layout) and check the columns are not cutting off the last character of any cell. If they are, nudge the column boundary one notch wider, or set the print scaling to Fit All Columns on One Page via Page Layout > Scale to Fit.
If data lands in an Excel Table through Power Query or an external connection, column widths can change when the query refreshes. Re-run AutoFit after the refresh, or call the AutoFit macro from your refresh routine so every refresh ends with clean widths.
Try these questions from our free Excel practice tests. The correct answer and an explanation follow each question.
Which one of the aforementioned Excel capabilities enables you to select/highlight every cell that contains a formula?
Answer: C. Go To Special
The 'Go To Special' feature in Excel (accessible via F5 or Ctrl+G, then 'Special...') provides advanced selection options, including the ability to highlight every cell that contains a formula. This is invaluable for auditing spreadsheets, understanding data dependencies, and quickly identifying all calculated values within a worksheet.
A developer is recording a macro that needs to perform a series of formatting steps starting from any active cell. To ensure the macro's actions are recorded based on their position relative to the starting cell (e.g., move one cell right), which setting must be enabled before performing the actions?
Answer: D. Use Relative References
By default, Excel records macros with absolute references (e.g., Range("C5").Select). Enabling 'Use Relative References' records actions based on their offset from the active cell, allowing the macro to be run from any starting point on the worksheet with the same relative effect.
What happens when you enter a formula that creates a circular reference in Excel?
Answer: C. Excel displays a warning and may return 0 or an error
By default Excel warns the user about circular references and typically shows 0 unless iterative calculation is enabled.
You have an Excel table named 'SalesData' with columns for '[Units]' and '[Unit_Price]'. You want to add a new calculated column named '[Revenue]' that multiplies the units by the unit price for each row. Which formula, when entered into the first cell of the new column, will correctly and automatically populate for all other rows in the table?
Answer: B. =[@[Units]]*[@[Unit_Price]]
In an Excel table, using `[@ColumnName]` creates a structured reference that refers to the value in the specified column for the current row. This syntax allows Excel to automatically fill the formula down the entire column, creating a calculated column.
Take the full Excel practice test
Many readers pair this guide with the excel latest version to check their readiness before exam day.
AutoFit is one of those features you only notice when it is missing. Learn the ribbon path (Home > Format > AutoFit), the boundary double-click, and the Windows Key Tip sequences, and pick whichever is fastest at the moment.
Treat AutoFit as a starting point, not a final layout. Run it to clean up imported data, then set manual widths for anything you share or print. Lock down PivotTable widths so they survive refresh, and use Center Across Selection instead of merges to avoid the AutoFit-merge clash.
If you re-format the same sheets every week, record or paste the AutoFit macro and store it in your Personal Macro Workbook (PERSONAL.XLSB) so it is available in every file you open.