Changing the Column Width or Row Height automatically to fit the contents is called AutoFit in Excel.
4 different methods to AutoFit Rows and Columns in Excel are explained in this blog post and the following is the data used for explaining these methods.
![](https://xlncad.com/wp-content/uploads/2022/03/Autofit-Rows-and-Columns-in-Excel_1-1-1024x920.png)
Table of Contents
AutoFit Rows and Columns manually
Select the entire Worksheet by clicking on the small triangle in the top left corner of the Worksheet.
Double-click on the border of any Column header to AutoFit Column Widths. Double-click on the border of any Row header to AutoFit Row Heights.
![](https://xlncad.com/wp-content/uploads/2022/03/AutoFit-Rows-and-Columns-Gif2.gif)
Note: Ctrl + A is the Keyboard shortcut to select the entire Worksheet.
Keyboard shortcut to AutoFit Rows and Columns
Alt + H + O + I is the Keyboard shortcut to AutoFit Column Width in Excel.
To AutoFit Row Height, press Alt + H + O + A
![](https://xlncad.com/wp-content/uploads/2022/03/AutoFit-Rows-and-Columns-Gif2-3.gif)
AutoFit Rows and Columns using the options in the Excel Ribbon
To AutoFit Columns,
select the data > in the Home tab of the Excel ribbon > Format > AutoFit Column Width
![](https://xlncad.com/wp-content/uploads/2022/03/Autofit-Rows-and-Columns-in-Excel_2-1024x742.png)
Similarly, select AutoFit Row Height to AutoFit Rows.
![](https://xlncad.com/wp-content/uploads/2022/03/Autofit-Rows-and-Columns-in-Excel_3-1024x773.png)
Macro to AutoFit Rows and Columns
The following code when executed will AutoFit the Rows and Columns of an Excel Worksheet.
Sub AutoFitRowsAndColumns() Cells.EntireColumn.AutoFit Cells.EntireRow.AutoFit End Sub
![](https://xlncad.com/wp-content/uploads/2022/03/AutoFit-Rows-and-Columns-Gif3-1.gif)