Public Sub AutoFit()
Dim xl As Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
Dim i As Integer
Set xl = Application
Set wb = ThisWorkbook
Set ws = wb.Sheets(1)
For i = 1 To 10
ws.Columns(i).EntireColumn.AutoFit
Next
Set ws = Nothing
Set wb = Nothing
Set xl = Nothing
End Sub