For Each ws In ActiveWorkbook.Worksheets
ws.Select
Cells.EntireColumn.AutoFit
Cells.EntireRow.AutoFit
Columns("G:G").Delete
Columns("E:E").Delete
Next ws
I know you just modified the OP's posted code, but I wanted to point out for the OP that you do not have to select the worksheet in order to do what he wants to it..."entire" is not a valid reference.
Code:For Each ws In ActiveWorkbook.Worksheets ws.Select Cells.EntireColumn.AutoFit Cells.EntireRow.AutoFit Columns("G:G").Delete Columns("E:E").Delete Next ws
For Each ws In ActiveWorkbook.Worksheets
ws.Cells.EntireColumn.AutoFit
ws.Cells.EntireRow.AutoFit
ws.Columns("G:G").Delete
ws.Columns("E:E").Delete
Next ws
For Each ws In ActiveWorkbook.Worksheets
With ws
.Cells.EntireColumn.AutoFit
.Cells.EntireRow.AutoFit
.Columns("G:G").Delete
.Columns("E:E").Delete
End With
Next ws
Good point.I know you just modified the OP's posted code, but I wanted to point out for the OP that you do not have to select the worksheet in order to do what he wants to it...
Exactly where did you add it?I added a msg box and it is stuck on the last worksheet in the book.
For Each ws In ActiveWorkbook.Worksheets
[COLOR=#ff0000]MsgBox ws.Name[/COLOR]
With ws
.Cells.EntireColumn.AutoFit
.Cells.EntireRow.AutoFit
.Columns("G:G").Delete
.Columns("E:E").Delete
End With
Next ws