![]() |
Autofit column width of all worksheets in active workbook - an example
No question here, just a procedure for the archive.
Search criteria: Autofit auto fit width of all columns in an worksheets work sheets active workbook justify width all column in work book automatically programmatically macro to resize column width Sub ColumnsAutoFitAllSheets() 'AutoFit all column widths in all worksheets in workbook Application.ScreenUpdating = False For i = 1 To Sheets.Count Sheets(i).Select Cells.EntireColumn.AutoFit Range("A1").Select Next Application.ScreenUpdating = True End Sub |
Autofit column width of all worksheets in active workbook - an example
DataFreakFromUtah,
A bit shorter and a bit more explicit, '***** Sub test() Dim wks As Worksheet For Each wks In ActiveWorkbook.Worksheets wks.Columns.AutoFit Next End Sub '***** Variants: For Each wks In ThisWorkbook.Worksheets For Each wks In ActiveWorkbook.Worksheets For Each wks In Workbooks("Book1").Worksheets -- Also, your code will crash if there is a Chart sheet in the workbook. Regards, Anders Silven "DataFreakFromUtah" skrev i meddelandet om... No question here, just a procedure for the archive. Search criteria: Autofit auto fit width of all columns in an worksheets work sheets active workbook justify width all column in work book automatically programmatically macro to resize column width Sub ColumnsAutoFitAllSheets() 'AutoFit all column widths in all worksheets in workbook Application.ScreenUpdating = False For i = 1 To Sheets.Count Sheets(i).Select Cells.EntireColumn.AutoFit Range("A1").Select Next Application.ScreenUpdating = True End Sub |
All times are GMT +1. The time now is 10:07 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com