Auto-fit Columns Using Macros

If you want to make your columns more presentable in your excel then use macros to auto-fit them. We understand in excel column widths are all over and that does not look cool and presentable. 

Purpose of this tutorial: to learn how to Auto-fit all columns by using macros to fit to its contents in excel.

Before following the procedure of this tutorial make sure you have enabled the Excel’s Developer Tab.

Previously In macros:How to Insert Numbers Using Macros in Excel

STEP 1: GO TO DEVELOPER> CODE> VISUAL BASIC> COPY/PASTE THE CODE BELOW > CLOSE THE WINDOW

Copy The Code Below;

Sub AutoFitAllColumns()
Cells.Select

‘See the magic happen!
Cells.EntireColumn.AutoFit
End Sub

Auto-fit Columns

STEP3. Now open the sheet that contains the data to test it out.

Afterwards, follow this: Go to Developer > Code > Macros > Run

Auto-fit Columns

Now all of the columns are automatically fitted.

Auto-fit Columns