Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
autofit row text (wrapped) without changing column width? | Excel Discussion (Misc queries) | |||
format:column width: autofit selection | Setting up and Configuration of Excel | |||
autofit cells in column width | Excel Discussion (Misc queries) | |||
Autofit Row height or Column Width does not work | Excel Discussion (Misc queries) | |||
autofit Column width- Ajit | Excel Discussion (Misc queries) |