Reputation: 11
What VBA command can I use to set a standard zoom level for all excel worksheets, that also allows me to increase/decrease the zoom level by 10% by clicking?
FYI: I am creating two buttons (zoom in and zoom out) in excel that allows user to adjust zoom settings from title page of document - will adjust entire workbook.
Thanks!
Upvotes: 1
Views: 5352
Reputation: 277
I have tested this and it works but I still need to have a starting zoom level of 75 or something. How can I adjust with that as the starting point? – Eric Walker Oct 5 at 20:44
you can use
Public Sub Auto_Open()
ActiveWindow.zoom = 75
End Sub
Upvotes: 2
Reputation: 277
You can use ActiveWindow.Zoom
.
ActiveWindow.Zoom = 70
ActiveWindow.Zoom = 10
ActiveWindow.Zoom = 120
ActiveWindow.Zoom = 110
ActiveWindow.Zoom = 100
Upvotes: 0
Reputation: 180
This code is untested but should give you the idea... Link your buttons to the DecreaseZoom and IncreaseZoom subroutines.
Public ZoomSetting As Integer
Sub DecreaseZoom
If ZoomSetting = 0 Then
ZoomSetting = 100
End If
If ZoomSetting > 10 Then
ZoomSetting = ZoomSetting - 10
SetZoom
End If
End Sub
Sub IncreaseZoom
If ZoomSetting = 0 Then
ZoomSetting = 100
End If
If ZoomSetting < 400 Then
ZoomSetting = ZoomSetting + 10
SetZoom
End If
End Sub
Sub SetZoom()
Dim CurrentWS As Worksheet, TempWS As Worksheet
CurrentWS = ActiveWorksheet
For Each TempWS In Worksheets
TempWS.Select
ActiveWindow.Zoom = ZoomLevel
Next
CurrentWS.Select
End Sub
FYI, if you select all worksheets in your workbook using the tabs you can then set the zoom and it will apply to all worksheets.
Upvotes: 1
Reputation: 1148
Use Activewindow.zoom = activewindow.zoom -10
to zoom out, and Activewindow.zoom = activewindow.zoom +10
to zoom in.
Upvotes: 0