Resetting Multiple Sheets on Workbook Open

drewberts

Board Regular
Joined
Sep 5, 2013
Messages
177
Office Version
  1. 365
Platform
  1. Windows
I'm trying to set zoom level as well as each sheet having the last empty cell selected. I have a button on each sheet which manually selects and scrolls to the last cell using:-

ActiveSheet.ShowAllData
Range("Table1").Cells(1, 2).End(xlDown).Offset(1).Select
ActiveWindow.ScrollColumn = 1

This works fine when clicking the button but I want to automate this for each sheet on workbook_open. I'm using the following (which I know is wrong, but I don't know why):-

Private Sub Workbook_Open()
On Error Resume Next
Application.ScreenUpdating = False

Dim ws As Worksheet

For Each ws In Worksheets
ws.Select
ActiveWindow.Zoom = 75
ActiveSheet.ShowAllData
Range("Table1").Cells(1, 2).End(xlDown).Offset(1).Select
ActiveWindow.ScrollColumn = 1
Range("Table2").Cells(1, 2).End(xlDown).Offset(1).Select
ActiveWindow.ScrollColumn = 1
Range("Table3").Cells(1, 2).End(xlDown).Offset(1).Select
ActiveWindow.ScrollColumn = 1
Next ws

Application.ScreenUpdating = True
End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Have you tried stepping through it manually to see what it does? You'll have to put it into a standard module for that, but it should show you what's "not working". To me, it looks like it should do what your individual 3 line code does only in each worksheet.

You might comment out the "on error resume next" and "screenupdating" lines and make sure it's not finding an error and skipping something.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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