sooty8
09-23-2011, 04:27 AM
Hi
I have used the macro recorder code below
Sub AutoFitSheets()
'
' AutoFitSheets Macro
'
'
Sheets("Sheet2").Select
Columns("A:K").Select
Selection.Columns.AutoFit
Sheets("Sheet3").Select
Columns("A:K").Select
Selection.Columns.AutoFit
Sheets("Sheet4").Select
Columns("A:K").Select
Selection.Columns.AutoFit
Sheets("Sheet5").Select
Columns("A:K").Select
Selection.Columns.AutoFit
Sheets("Sheet6").Select
Columns("A:K").Select
Selection.Columns.AutoFit
End
Sub
my question is that I really don't know how many sheets will be in the workbook it could be 2 Sheets to a maximum of 25 Sheets is it possible to just have Autofit run on all sheets within the workbook excluding Sheet1 which is the master sheet for the workbook.
Regards
Sooty 8
I have used the macro recorder code below
Sub AutoFitSheets()
'
' AutoFitSheets Macro
'
'
Sheets("Sheet2").Select
Columns("A:K").Select
Selection.Columns.AutoFit
Sheets("Sheet3").Select
Columns("A:K").Select
Selection.Columns.AutoFit
Sheets("Sheet4").Select
Columns("A:K").Select
Selection.Columns.AutoFit
Sheets("Sheet5").Select
Columns("A:K").Select
Selection.Columns.AutoFit
Sheets("Sheet6").Select
Columns("A:K").Select
Selection.Columns.AutoFit
End
Sub
my question is that I really don't know how many sheets will be in the workbook it could be 2 Sheets to a maximum of 25 Sheets is it possible to just have Autofit run on all sheets within the workbook excluding Sheet1 which is the master sheet for the workbook.
Regards
Sooty 8