VBA: Autofit All Columns Used
A popular Yahoo Search the past week has been to Autofit All Columns used in a worksheet from VBA. Combining the VBA to Autofit A Range, Count the Number of Used Columns, and a loop will do just that.
The following code autofits from VBA all used columns:
Sub AutofitAllUsed()
Dim x As Integer
For x = 1 To ActiveSheet.UsedRange.Columns.Count
Columns(x).EntireColumn.autofit
Next x
End Sub
Can't get the tutorial to work for you? Need help with your code?
Get answers right away at our AE Excel Support Forums!
Get answers right away at our AE Excel Support Forums!



It works! After much searching, I’m very pleased and very grateful!
Wow ! Thanks !