Sub ResetView() Dim sheet As Object For Each sheet In ActiveWorkbook.Sheets sheet.Activate ActiveSheet.Range("A1").Select ActiveWindow.Zoom = 100 Next sheet ActiveWorkbook.Sheets(1).Activate If ActiveWorkbook.Path = "" Then Application.Dialogs(xlDialogSaveAs).Show Else ActiveWorkbook.Save End If End Sub
This macro performs five tasks.
- Set the selected cell in all sheets to A1.
- Set the zoom of all sheets to 100%.
- Scroll to the top.
- Activate the first sheet.
- Save the workbook.
It is useful when used as an add-in.
How to create macros and add-ins
If you save the macro as an add-in (.xlam), you can use it in all workbooks. It is easy and recommended to add it to the Quick Access Toolbar.
Create an add-in (.xlam)
- Open the editor from the “Developer > Visual Basic”. If the Developer tab is not displayed, go to “File > Options > Customize Ribbon” and check the Developer checkbox.
- Go to “Insert” and add “Module”.
- Paste the code into “Module1” (the name does not have to be Module1).
- Save the Excel book with the file extension “.xlam”.
Add to Quick Access Toolbar
- Click the arrow on the right end of the Quick Access Toolbar.
- Click on “More Commands”.
- Under “Choose commands from” select “Macros”.
- Select the saved macro and click “Add”.
- Close with “OK.” A macro button is added to the Quick Access Toolbar.