Setting all Excel sheets at a defined zoom level

前端 未结 3 1994
说谎
说谎 2020-12-28 14:30

I have more than twenty sheets in an Excel workbook (file). Is there some code snippet or a command I could apply/use so that all sheets could be reset to let\'s say 85% zoo

相关标签:
3条回答
  • 2020-12-28 14:58
    Sub SetZoom()
        Dim ws As Worksheet
    
        For Each ws In Worksheets
            ws.Select
            ActiveWindow.Zoom = 85 ' change as per your requirements
        Next ws
    End Sub
    

    BTW, if you simply select all worksheets in your workbook using the tabs you can then set the zoom to 85% and it will apply to all worksheets

    0 讨论(0)
  • 2020-12-28 15:07

    Option Explicit
    
    Sub FixSheets()
        Dim ws As Worksheet
        For Each ws In Worksheets
            ws.Activate
            ws.UsedRange.Select
            ActiveWindow.Zoom = True 'Zoom sur la sélection
            ActiveCell.Select
        Next ws
    End Sub
    
    0 讨论(0)
  • 2020-12-28 15:16
    Sub SetZoom()
    
    Dim ws As Worksheet
    Application.ScreenUpdating = False    'Optional
    For Each ws In ActiveWorkbook.Worksheets
        ws.Activate
        ActiveWindow.Zoom = 85
    Next
    Application.ScreenUpdating = True
    
    End Sub
    

    This code is similar from the above, but it is not necessary to select all worksheets in your workbook before running the macro. Instead of using ws.Select and Next ws that not work correctly unless you select the worksheets, change to ws.Activate and Next to set the zoom for all the sheets. As optional, the ScreenUpdating can be disabled for a workbook with a lot of sheets.

    0 讨论(0)
提交回复
热议问题