Brain dead - what am i doing wrong

wmtsub

Active Member
Joined
Jun 20, 2018
Messages
322
For Each ws In ActiveWorkbook.Worksheets
ws.Select
entire.Columns.AutoFit
entire.Rows.AutoFit
Columns("G:G").EntireColumn.Delete
Columns("E:E").EntireColumn.Delete
Next ws
 
I don't think it shouldn't make any difference, but what happens if you change this line:
Code:
For Each ws In ActiveWorkbook.Worksheets
to this:
Code:
For Each ws In Worksheets

I don't think you need the "ActiveWorkbook" part - I never use it!

Also, what version of Excel are you using?
Is it a Windows or Mac version?
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Varyies but so far its been in the 50's.
I got it to work this AM , its a work around but it works.
I had to expand all the columns first then it would shrink ok.
And I had to activate each sheet instead of select (initial error I think)


For Each ws In ThisWorkbook.Worksheets
ws.Activate
Columns("G:G").Delete
Columns("E:E").Delete
Cells.Select
Selection.ColumnWidth = 80
Cells.EntireRow.AutoFit
Cells.EntireColumn.AutoFit
Next ws
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top