AutoFit Rows and Columns in Excel (4 Ways)

AutoFit resizes columns and rows to fit their contents, so text stops spilling over and #### turns back into numbers. The fastest way: select the sheet with Ctrl + A and double-click any column border.

Column shortcutAlt, H, O, I
Row shortcutAlt, H, O, A
Works inAll Excel versions

The data

Excel data with columns too narrow for their contents

1. Double-click a border

  1. Select the whole sheet with Ctrl + A, or click the triangle at the top-left corner of the grid.
  2. Double-click the border between any two column letters to AutoFit all columns.
  3. Double-click the border between any two row numbers to AutoFit all rows.
Double-clicking column and row borders to AutoFit in Excel

To fit just one column, double-click the right border of its letter.

2. Keyboard shortcuts

Select the cells, then press the keys one after another (not together):

To Press
AutoFit column width Alt, H, O, I
AutoFit row height Alt, H, O, A
AutoFit columns and rows with keyboard shortcuts

3. From the ribbon

Select the data, then go to Home → Format → AutoFit Column Width or AutoFit Row Height.

Home tab Format menu with AutoFit Column Width
Home tab Format menu with AutoFit Row Height

4. A macro for every sheet

This fits only the used part of the active sheet, which is faster than the whole grid:

Sub AutoFitSheet()
    ActiveSheet.UsedRange.Columns.AutoFit
    ActiveSheet.UsedRange.Rows.AutoFit
End Sub

Macro autofitting rows and columns

When AutoFit doesn’t work

Problem Fix
Merged cells don’t resize AutoFit ignores merged cells. Use Center Across Selection instead of merging
Wrapped text row stays short Turn on Wrap Text first, then AutoFit the row height
Column is far too wide One long cell (often a title) sets the width. AutoFit the data rows only
#### after AutoFit The number is still wider than the maximum; use a shorter number format

Frequently asked questions

What is the shortcut for AutoFit in Excel?

Alt, H, O, I for column width and Alt, H, O, A for row height. Press the keys one after another.

Related