Lovelylou79
New Member
- Joined
- Sep 4, 2017
- Messages
- 37
Hi Again VBA Experts,
I am trying to select all sheets in my workbook after and inclusive of Sheets("ps"), then format each sheet.
I have the following code. It selects all sheets, all sheets widen to 100, but only the first sheet (ps) is then reformatted to Autofit.
Can you please point out where my code is failing. It seems to work during a step through.
Sub FormatMySheets()
Dim i As Long
'Select All sheets
Sheets("ps").Activate
For i = ActiveSheet.Index To Sheets.Count
Sheets(i).Select Replace:=False
Cells.Select
With Selection
.ColumnWidth = 100
.EntireColumn.AutoFit
.EntireRow.AutoFit
End With
Next i
End Sub
Thank you
I am trying to select all sheets in my workbook after and inclusive of Sheets("ps"), then format each sheet.
I have the following code. It selects all sheets, all sheets widen to 100, but only the first sheet (ps) is then reformatted to Autofit.
Can you please point out where my code is failing. It seems to work during a step through.
Sub FormatMySheets()
Dim i As Long
'Select All sheets
Sheets("ps").Activate
For i = ActiveSheet.Index To Sheets.Count
Sheets(i).Select Replace:=False
Cells.Select
With Selection
.ColumnWidth = 100
.EntireColumn.AutoFit
.EntireRow.AutoFit
End With
Next i
End Sub
Thank you