This article highlights how to lock zoom in excel. The zoom feature in Excel is a great way to quickly maximize or minimize the view as required. This allows us to get a close-up view by zooming in and see more of the sheet at a reduced size by zooming out.
How to Lock Zoom in Excel: Steps Using a VBA Code
Now assume you have a worksheet containing many objects and shapes. Then zooming out the sheet may confuse users by making the objects smaller. This may lead to more complications especially if the objects are linked to macros. You need to lock the zoom feature for the users in such scenarios.
Unfortunately, there is no inbuilt or direct way to do that in Excel. You can use a VBA code to change the zoom to a fixed level as soon as a user tries to zoom in or out. Follow the steps below to build the VBA code.
📌 Step 1: Open VBA Window
- First, press ALT+F11Â to open the VBA window. Then select Insert >> Module.
📌 Step 2: Create Sub Procedure
Sub LockZoomInExcel()
End Sub
📌 Step 3: Add Do Loop to Lock Zoom
Sub LockZoomInExcel()
Do
Loop While True
End Sub
📌 Step 4: Add IF Statement to Reset Zoom
Sub LockZoomInExcel()
Do
If ActiveWindow.Zoom <> 100 Then
ActiveWindow.Zoom = 100
End If
Loop While True
End Sub
Read More: How to Zoom Out in Excel
📌 Step 5: Include DoEvents Statement
(Here you get the complete code)
Sub LockZoomInExcel()
Do
If ActiveWindow.Zoom <> 100 Then
ActiveWindow.Zoom = 100
End If
DoEvents
Loop While True
End Sub
📌 Step 6: Run the Code
- Now keep the cursor on the code. Then press F5 to run it. After that, return to your worksheet.
Read More: Excel VBA: Zoom to Fit Screen
📌 Step 7: Observe Results
- Now you won’t be able to zoom the page anymore. VBA will reset the zoom instantly. But, you need to rerun the code every time you reopen the document.
Read More: How to Zoom in When Zoom Slider Is Not Working in Excel
Things to Remember
- Don’t forget to save the file as a macro-enabled workbook.
- You need to rerun the code every time you reopen the document.
Download Practice Workbook
You can download the following file to practice along with it.
Conclusion
Now you know how to lock zoom in excel. Did this solve your problem? Do you have any further queries or suggestions?? Please let us know using the comment section below.