Excel Autofit macro settings

Hey All,

I have an Excel file in which the rows and columns are not well arranged.

So I thought of using the Autofit macro script found in here.

Do I have to change any settings apart from enabling macro in Excel ?

Hi @uio

Use this Macros Code:

Sub AutoFitRowsAndColumns()
    Dim ws As Worksheet
    Set ws = ThisWorkbook.ActiveSheet
    
    ws.Rows.AutoFit
    ws.Columns.AutoFit
End Sub

Method Name: AutoFitRowsAndColumns
AutoFitRowsAndColumns.txt (151 Bytes)

Paste this code in text file. and pass the Method name as AutoFitRowsAndColumns

Hope it helps!!

I have the script to achieve the task. My question is about the settings I need to change.

2 Likes

Hi,

You don’t have to change anything in setting. Just enabling macro is enough.

Thanks

Hi @uio

Follow the below steps in the thread.

Regards