In Excel for Microsoft 365 on Windows, select the columns you want to fit and press Alt, H, O, I in sequence to AutoFit their widths; for row heights, press Alt, H, O, A. To fit both dimensions, run both shortcuts. Excel sizes the selected rows or columns to display their contents, rather than resizing a single cell independently.
What AutoFit changes
Excel cells are arranged in rows and columns, so cells in the same column share one width and cells in the same row share one height. AutoFit therefore changes a whole column’s width or a whole row’s height, even if you select just one cell inside it. It calculates a suitable size from the visible contents and the current formatting.
AutoFit Column Width is useful when a heading or entry is cut off, while AutoFit Row Height is useful when text wraps onto multiple lines. For example, if column B contains short product codes in most rows but one long product name, fitting column B makes the entire column wide enough for the longest displayed entry. That can improve readability, but it can also make a worksheet much wider.
AutoFit is an adjustment you apply, not a general command to make every cell a different size. A worksheet can have different widths for different columns and different heights for different rows, but not varying cell widths within one column or varying cell heights within one row.
Use the Windows keyboard shortcuts
The keyboard sequences use Excel’s ribbon KeyTips. Press the keys one after another; do not hold all of them down together. First select the relevant columns, rows, or cells, then use the sequence that matches the dimension you want to adjust:
- Fit column width: Press Alt, then H, O, and I. The sequence opens the Home tab’s Format commands and chooses AutoFit Column Width.
- Fit row height: Press Alt, then H, O, and A to choose AutoFit Row Height.
- Fit both: Apply the column-width sequence and then the row-height sequence to the same selection. You can also use the Format menu options described below.
These sequences are handy when cleaning a data table or formatting a report without reaching for the mouse. If a key press appears to do something unexpected, confirm that the worksheet is active and that you are not editing text inside a cell. Press Esc to leave cell editing, select the intended range, and try the sequence again. KeyTip behavior can vary in some ribbon configurations, so the Home tab’s Format menu is a reliable alternative.
Select the right rows or columns first
Selection determines how much of the worksheet Excel adjusts. Click a column letter to select that entire column, or a row number to select that entire row. To select adjacent columns or rows, drag across their headings, or select the first heading and Shift-click the last. For nonadjacent selections, use Ctrl-click on Windows to add individual headings or ranges.
If you select a cell range rather than whole columns, AutoFit adjusts the rows and columns that intersect the selection. For instance, selecting B2:D20 and choosing AutoFit Column Width adjusts columns B through D based on their contents; it does not create separate widths for rows 2 through 20. If you select just B2, Excel adjusts column B or row 2, depending on which AutoFit command you use.
To adjust the whole worksheet, click the Select All button at the top-left corner where the row numbers and column letters meet, then run the column and row commands. This can make a large sheet easier to inspect, but it may also produce very wide columns because Excel considers long values anywhere in the selected columns. For a more controlled result, select only the data columns or rows that need attention.
Use the ribbon or a mouse instead
The ribbon offers the same AutoFit commands as the Windows shortcuts. Select the target rows or columns, then choose Home > Format > AutoFit Column Width or Home > Format > AutoFit Row Height. The Format menu also includes fixed sizing options, which are useful when you want a consistent width or height rather than a content-based fit.
With a mouse, point at the boundary between two column letters or row numbers. When the pointer changes to a resize indicator, double-click the boundary to AutoFit that column or row. To adjust several columns at once, select their headings first and double-click a boundary between any two selected column headings. The selected columns are fitted to their respective contents. Dragging the boundary instead of double-clicking sets a size manually.
For example, if column C is too narrow to show email addresses, select column C and double-click the right edge of its heading. If a note in row 12 wraps to several lines, double-click the boundary below row 12 to fit its height. The ribbon and keyboard options are often more precise when you need to apply a particular dimension to a carefully selected range.
How wrapping and formatting affect the result
AutoFit uses more than the raw text. Font size, bold formatting, number formats, and other display choices can change how much space an entry takes. A date formatted to show a long month name may need more width than the same date displayed numerically. A large font or bold heading can also make a column or row expand.
Wrap Text changes the way long entries use space. With wrapping enabled, text can continue on additional lines within the existing column width, and the row may need extra height to display those lines. A useful approach for long descriptions is to choose a reasonable column width, turn on Wrap Text from Home > Alignment > Wrap Text, then AutoFit the row height. This avoids making the whole column as wide as the longest description.
AutoFit is not a substitute for checking how the worksheet will be used. A column that fits every long note may push neighboring data off-screen or make printing awkward. Consider wrapping long text, widening only key columns, or setting a deliberate width for a report intended to print on a page.
Excel for Mac and Excel for the web
On a Mac, use the ribbon commands Home > Format > AutoFit Column Width and Home > Format > AutoFit Row Height after making the selection. You can also use the column or row heading boundary and double-click to fit it. The Windows Alt KeyTip sequences above are Windows shortcuts; do not assume they work the same way on a Mac, where the menu and keyboard conventions differ.
In Excel for the web, select the relevant headings or cells and use the Home tab’s Format options for AutoFit Column Width or AutoFit Row Height. Double-clicking a heading boundary is another practical method where the browser and pointer allow it. The exact keyboard behavior can depend on the browser and its own shortcuts, so the ribbon command is the clearest cross-platform route.
If you are following instructions written for a different Excel version, look for the same AutoFit names under Format. Ribbon layouts can change, but the distinction remains: one command fits column width and the other fits row height.
Common problems and practical fixes
If the result does not look right, the issue is often the selection or the cell formatting rather than a faulty shortcut. Check these common cases:
- The entire sheet becomes too wide: A long entry somewhere in a selected column may be setting its width. Fit only the columns that need it, or use Wrap Text for lengthy descriptions.
- A row does not show all wrapped text: Select the affected row and use AutoFit Row Height. A manually specified height can prevent the text from displaying as expected, so reapply AutoFit or adjust the row boundary.
- A column appears to have a large blank gap: Check for unusually long values, large fonts, or formatting that affects display. Also check whether the column contains a cell with text that should be wrapped rather than displayed on one line.
- A selected cell seems to change neighboring cells: That is normal. Column width and row height are shared by every cell in that column or row.
- The keyboard sequence does not run: Make sure you press the keys in sequence, not simultaneously, and that you are not editing a cell. Use the Home > Format menu if KeyTips are unavailable or behave differently in your setup.
Merged cells are a notable exception. AutoFit may not calculate the row height or column width as expected for merged ranges. If a merged heading is clipped, try unmerging it and using Center Across Selection for a similar visual effect, or set the row height and column width manually. Manual sizing gives you control, but it may need revisiting if the text or font later changes.
AutoFit versus fixed sizing
AutoFit is best when the goal is to show the current contents with minimal manual adjustment. Fixed sizing is better when consistency matters more than fitting every value. For example, a printed inventory report may look cleaner with all quantity columns the same width, even if one column could be slightly narrower.
Choose Home > Format > Column Width or Home > Format > Row Height to enter a specific size. Another option is to drag the boundary until the result looks right. A practical workflow is to AutoFit a draft, inspect the widest columns, then set a smaller standard width and wrap text in the columns that contain long descriptions.
Remember that a fit is based on content as it appears at the time of adjustment. If you later add a much longer value, the column may not automatically widen to accommodate it. Run AutoFit again when needed, or use wrapping and a fixed layout when entries change frequently.
Frequently Asked Questions
What is the shortcut to AutoFit a column in Excel?
On Windows, select the column or cells in it, then press Alt, H, O, and I in sequence. This chooses AutoFit Column Width from the Home tab’s Format commands.
What is the shortcut to AutoFit row height?
Select the relevant row or cells, then press Alt, H, O, and A in sequence on Windows. It adjusts row height to display the contents, including wrapped lines where applicable.
Can I resize one cell without changing the rest of its row or column?
No. Excel assigns width to a whole column and height to a whole row, so changing one cell’s dimensions changes its neighboring cells in that row or column too. Use text wrapping, alignment, or merged-cell alternatives to change how content appears without giving one cell independent dimensions.
Why does AutoFit not expand a column when I type a longer value?
AutoFit sets a suitable size when you run the command; it is not a permanent rule that continually widens a column for every new entry. Run AutoFit again, double-click the column boundary, or use Wrap Text if the data changes regularly.
How do I fit all columns and rows at once?
Click the Select All button at the worksheet’s top-left corner, then run AutoFit Column Width and AutoFit Row Height from Home > Format. On Windows, use the two corresponding Alt KeyTip sequences. Check the result afterward, since a single long entry can make a column unusually wide.
Related
- Excel CSV Delimiter: How to Change the File Separator
- Excel Export to CSV: Does It Keep Cell Formatting?
- Excel: Disable the Quick Analysis Popup
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- How to Stop Solver in Excel Without Losing Your WorkTo stop a Solver run in Excel for Microsoft 365 on Windows, click Stop in the Solver Status…
- Track Changes in Word: Turn It On, Review, and Accept EditsIn Microsoft Word for Microsoft 365 on Windows, open the Review tab and click Track Changes to record…
- Excel Dropdown List Without Blanks: Keep Options CleanYes. In Excel for Microsoft 365, use a FILTER formula to create a helper list containing only nonblank…
- How to Create an Outlook Signature on an HP LaptopTo create an Outlook signature on an HP laptop, open Outlook, go to its signature settings, write and…
- Remove an Extra Page After a Section Break in WordTo remove an extra page after a section break in Word, show formatting marks with Ctrl+Shift+8 on Windows…
- Excel Workbook Size Limit: Memory, File Size, and LimitsFor Excel for Microsoft 365 on Windows, there is no single fixed maximum file size for a modern…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.