VBA to change zoom of all Worksheets in a workbook Excel 2019 for Mac

SanjayGMusafir

Well-known Member
Joined
Sep 7, 2018
Messages
1,513
Office Version
  1. 2024
Platform
  1. Windows
Hi Experts,
Here comes a new problem. With Excel 2019 for Mac, when you open a file, it doesn't display Customised Macro Buttons.

The workaround is to change the zoom level and they all magically appear.

So I wrote a code to change zoom level of all worksheets in one click. But it seems to be not working. It only changes zoom level of one active window and doesn't move to another sheets. There must be some technical error.

Please help

Code:
Sub ZoomAll()
'
' ZoomAll Macro
'


' To change zoom value of all windows


    Dim wsheet As Worksheet
    
    For Each wsheet In ActiveWorkbook.Worksheets
    ActiveWindow.Zoom = 150
    ActiveWindow.Zoom = 135
    Next wsheet
    
    ActiveWorkbook.Save
    
End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Only the active sheet can be zoomed.

So use this script.
When you activate the sheet the zoom will take place
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on any sheet tab
Select View Code from the pop-up context menu
In upper left corner of screen double click on This Workbook
Paste the code in the VBA edit window
Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
'Modified  10/17/2018  10:22:33 AM  EDT
ActiveWindow.Zoom = 150
End Sub

This works on Excel 2013 for PC
Not sure about 2019 for Mac
Try it and see
 
Last edited:
Upvote 0
Or do it this way:

But then you would have to do it again every time you add a new sheet.
Code:
Sub Zoom_Me()
'Modified 10/17/2018 10:31 AM  EDT
Application.ScreenUpdating = False
Dim i As Long
    For i = 1 To Sheets.Count
        Sheets(i).Activate
        ActiveWindow.Zoom = 150
    Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
@My Aswer Is This

I need to modify my code where it makes every sheet active by itself and changes the zoom level.

Only the active sheet can be zoomed.

So use this script.
When you activate the sheet the zoom will take place
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on any sheet tab
Select View Code from the pop-up context menu
In upper left corner of screen double click on This Workbook
Paste the code in the VBA edit window
Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
'Modified  10/17/2018  10:22:33 AM  EDT
ActiveWindow.Zoom = 150
End Sub

This works on Excel 2013 for PC
Not sure about 2019 for Mac
Try it and see
 
Upvote 0
Not sure what your now asking for.
Did you try my second post.

And why do you have:
Zoom 150
And then:
The Zoom 135
 
Upvote 0
@My Aswer Is This

This code worked for me. Thanks

Or do it this way:

But then you would have to do it again every time you add a new sheet.
Code:
Sub Zoom_Me()
'Modified 10/17/2018 10:31 AM  EDT
Application.ScreenUpdating = False
Dim i As Long
    For i = 1 To Sheets.Count
        Sheets(i).Activate
        ActiveWindow.Zoom = 150
    Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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