![]() |
Autosize macro
How do I create a macro that autosizes all columns of every tab in the
workbook? |
Autosize macro
The following code will autofit the columns on all worksheets:
Sub Macro1() Dim i As Integer For i = 1 To Sheets.Count Sheets(i).Select Cells.Select Selection.Columns.AutoFit Next i End Sub David "SweetJebus" wrote in message ... How do I create a macro that autosizes all columns of every tab in the workbook? |
Autosize macro
Hi David,
It is rarely necessary, and usually inefficient. to make selections. To allow for possible hidden worksheets or the presence of sheets other than worksheets, perhaps try: '============= Public Sub Macro1() Dim i As Long For i = 1 To Sheets.Count Sheets(i).Columns.AutoFit Next i End Sub '<<============= --- Regards, Norman "Dove" wrote in message ... The following code will autofit the columns on all worksheets: Sub Macro1() Dim i As Integer For i = 1 To Sheets.Count Sheets(i).Select Cells.Select Selection.Columns.AutoFit Next i End Sub David "SweetJebus" wrote in message ... How do I create a macro that autosizes all columns of every tab in the workbook? |
All times are GMT +1. The time now is 02:06 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com