In Excel for Microsoft 365 on Windows, select the column or row and press Alt, H, O, I to AutoFit its width, or Alt, H, O, A to AutoFit its height. Press the keys in sequence, not all at once: these are ribbon Key Tips for Home > Format, and they resize the selection to fit its contents.
What AutoFit Does
AutoFit adjusts a column’s width or a row’s height to show the cell contents without unnecessary clipping. For a column, Excel considers the displayed contents of cells in that column; for a row, it adjusts height to accommodate the contents, including wrapped text when the row is set up for wrapping. It is a sizing command, not a command to change the font, shorten text, or resize every cell in the worksheet automatically.
For example, if column A contains short product codes but cell A12 contains “Replacement filter cartridge,” AutoFit Column Width can widen A to show that longer entry. If a cell contains a paragraph and Wrap Text is enabled, AutoFit Row Height can make the row taller so more lines are visible. The result depends on the values and formatting in the selected range, so an AutoFit column may become wider than you want if one cell has an unusually long description.
Windows Shortcuts for Columns and Rows
Excel’s Windows ribbon Key Tips provide separate commands for column width and row height. First select what you want to resize, then use the appropriate sequence:
- AutoFit Column Width: press Alt, then H, O, I.
- AutoFit Row Height: press Alt, then H, O, A.
These sequences correspond to Home, Format, AutoFit Column Width and Home, Format, AutoFit Row Height. You can press each letter after the previous one; holding Alt while typing the whole sequence is not necessary. If you press Alt and the Key Tips shown on your screen differ—for example, because of a different Excel language or keyboard setup—follow the displayed letters. Key Tips can vary with the ribbon configuration and localization.
The command acts on the selected rows or columns. If you have selected a cell range rather than entire columns, AutoFit applies to the rows or columns intersecting that selection. For a single cell, the command adjusts its containing column or row. This makes it useful for a small section of a sheet, but it also means selection matters: a mistaken full-column selection can change more of the layout than intended.
Selecting the Right Cells First
To AutoFit one column, click its letter heading, such as B, and run the column shortcut. To select neighboring columns, drag across their headings or click the first heading and Shift-click the last. You can also select a column and then use Ctrl+Space on Windows. For rows, click a row number or select a row with Shift+Space. After selecting the rows, use the row-height sequence.
To resize every column in a worksheet, select the whole sheet before running AutoFit Column Width. Click the small Select All button at the intersection of the row numbers and column letters, or use Ctrl+A when the worksheet grid has focus. Ctrl+A can behave differently inside a formatted Excel table: it may first select the table’s data, and pressing it again can expand the selection. Check the highlighted area before applying AutoFit, especially in a large workbook.
AutoFit is based on the selected rows or columns, not on only the cell where the active cursor happens to be. If you select several columns, Excel sizes each one according to its own contents. Selecting the entire sheet and AutoFitting all columns can be convenient, but one unusually long note may make its column very wide and leave less room for the rest of the worksheet.
Using the Ribbon or Mouse Instead
If you prefer not to use Key Tips, select the relevant rows or columns and choose Home > Format > AutoFit Column Width or Home > Format > AutoFit Row Height. The Format menu also includes fixed sizing commands, so make sure you choose AutoFit rather than Column Width or Row Height if your goal is to fit the contents.
A quick mouse method is to double-click the boundary between two column headings. To AutoFit column C, for instance, double-click the line between the C and D headings. For a row, double-click the boundary between its row number and the next one. If multiple columns or rows are selected, double-clicking a boundary can AutoFit the selected group. This is handy for an occasional adjustment, while the keyboard sequence is easier to repeat consistently.
Dragging a boundary is different: it sets a width or height based on where you release the mouse, rather than calculating an AutoFit size. Use dragging when you want a deliberate fixed size, such as making several columns the same width. Use AutoFit when the content should determine the size.
AutoFit, Wrap Text, and Fixed Sizes
AutoFit and Wrap Text solve related but different layout problems. AutoFit Column Width tries to make a column wide enough for its contents. Wrap Text keeps the column narrower and displays long entries on multiple lines within a cell. For a report with lengthy descriptions, wrapping plus AutoFit Row Height is often more readable than allowing one description to create a very wide column.
A practical approach is to set a reasonable width for the description column, turn on Home > Wrap Text, and then AutoFit the relevant rows. If you later change the column width, the line breaks can change, so you may need to AutoFit the row heights again. Conversely, if you need a consistent grid for printing or data entry, fixed column widths and row heights may be preferable to AutoFit.
Column width in Excel is not simply a number of pixels. It is measured in character-width units based on the workbook’s Normal style font, and the on-screen pixel appearance can vary with font, zoom, and display scaling. AutoFit aims to show the contents under the current formatting; it does not guarantee that a worksheet will have identical physical dimensions on every screen or printout.
Why AutoFit May Not Look Right
AutoFit cannot always produce the layout a reader expects. A common example is a cell with merged cells. Excel’s AutoFit commands do not reliably calculate the needed row height or column width for merged ranges. If a merged heading is clipped, try unmerging the cells and using Center Across Selection, adjusting the row or column manually, or changing the text layout. Those alternatives avoid relying on AutoFit to measure a merged area.
Another common issue is text that remains hidden after using AutoFit Row Height. Check whether Wrap Text is on, whether the row has a manually specified height, and whether the text is in merged cells. For wrapped text in ordinary cells, selecting the affected rows and running AutoFit Row Height often corrects the display. If a row still needs a particular height, set it manually through Home > Format > Row Height.
Numbers displayed as #### often mean the column is too narrow, so AutoFit Column Width may solve the problem. But widening is not a fix for every row of hash marks: Excel can also display them for negative date or time values. In that case, check the underlying value and number format rather than repeatedly widening the column. Also remember that a cell’s displayed result can be longer than its underlying value—for example, a date format may show a full weekday and month name—so AutoFit measures what the formatting displays.
Finally, formulas can return long text even when the formula itself is short. AutoFit responds to the displayed result, not the number of characters in the formula bar. If a formula result is exceptionally long, the resulting wide column may be inconvenient. Wrap the text, use a shorter display format, or choose a fixed width when the worksheet’s readability matters more than showing each value on one line.
Mac and Excel for the Web
The Windows sequence Alt, H, O, I relies on Windows ribbon Key Tips and should not be assumed to work the same way on a Mac. On Excel for Mac, select the cells, rows, or columns and use the ribbon’s Home > Format menu to choose AutoFit Column Width or AutoFit Row Height. Double-clicking a row or column boundary is another direct option. Mac keyboard mappings can differ by version, keyboard, and system settings, so use the visible menu command if you need a dependable method.
Excel for the web also has a ribbon and can expose keyboard access keys, but browser and operating-system shortcuts can affect how key combinations behave. If the Windows sequence does not trigger the intended command in a browser, use the Home tab’s Format menu or double-click the boundary in the worksheet grid. The same distinction between AutoFit and manually dragging a boundary applies.
When to AutoFit—and When Not To
AutoFit is useful after importing data, pasting text, changing number formats, or adding a new field whose values may be longer than existing entries. It can quickly reveal truncated labels and make a new worksheet easier to inspect. It is also useful during cleanup, provided you check the result rather than assuming the widest possible layout is the best one.
- Use AutoFit when you want a quick content-based size for ordinary cells.
- Use Wrap Text and AutoFit Row Height when long text should stay in a reasonably narrow column.
- Use a fixed width or height for consistent layouts, templates, and print-oriented sheets.
- Check merged cells, unusually long entries, and #### displays when the result does not change as expected.
AutoFit changes the worksheet’s presentation, not its underlying values or formulas. It does not delete content, alter calculations, or convert text to a different format. Still, it can make a workbook harder to navigate if applied indiscriminately to every column. A good final check is to scan for overly wide columns, clipped wrapped text, and rows that became much taller than their neighbors.
Frequently Asked Questions
What is the shortcut to AutoFit a column in Excel?
On Windows, select the column and press Alt, H, O, I in sequence. This follows Home > Format > AutoFit Column Width.
What is the shortcut to AutoFit row height?
Select the row or rows and press Alt, H, O, A in sequence on Windows. Excel adjusts the selected row heights to fit their contents, subject to limitations such as merged cells.
How do I AutoFit all columns in a worksheet?
Select the entire sheet using the Select All button at the grid’s upper-left corner, then run Alt, H, O, I. Confirm that the whole worksheet is selected; Ctrl+A may select only a table or data region on its first press.
Why does AutoFit not work on merged cells?
Excel does not reliably calculate AutoFit dimensions for merged ranges. Unmerge the cells, use Center Across Selection where suitable, or set the row height or column width manually.
Can I AutoFit with a mouse instead of a shortcut?
Yes. Double-click the boundary between column headings to AutoFit a column, or the boundary between row numbers to AutoFit a row. Dragging the boundary sets a size manually instead.
Related
- Excel Merge Cells in Each Row Without Losing Values
- Excel Merge Cells Greyed Out in a Table? Here’s Why
- Excel Merge Cells Across Rows: Methods, Limits, Tips
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Google Sheets Filter Shortcut: Apply a Filter FastIn Google Sheets in a web browser, press Ctrl+Shift+L on Windows, Linux, or ChromeOS to create a filter;…
- How to Delete an Unwanted Page in WordTo delete an unwanted page in Microsoft Word for Microsoft 365 on Windows, press Ctrl+G, type \page in…
- How to Delete a Page in Word After a Section BreakTo delete a page in Word that appears because of a section break, first show formatting marks with…
- Excel Data Validation for Text: Rules and ExamplesIn Excel for Microsoft 365 on Windows, use Data > Data Validation to limit text entries by character…
- Excel PivotTable Tips for Clearer ReportsFor better Excel PivotTables, start with a tidy, rectangular source table, then use Insert > PivotTable and place…
- How to Double Space References in WordTo double space references in Word, select the reference-list entries, open the Paragraph settings, and set Line spacing…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.