Office_Excel批量设置0值不显示和冻结窗格

为了让下发Excel表在查看时,具有良好体验,要设置0值不显示和冻结前几行。点此下载。

Sub FreezePanes()
    Dim MyPath$, MyName$, sh As Worksheet, w As WorksheetFunction
    Application.ScreenUpdating = False
    Set w = WorksheetFunction
    MyPath = ThisWorkbook.Path & ""
    MyName = Dir(MyPath & "*.xlsx")
    Set sh = ActiveSheet
    Do While MyName <> ""
        If MyName <> ThisWorkbook.Name Then
            With Workbooks.Open(MyPath & MyName)
                With .Sheets(1)
                    'Range("B7").Select   '设置冻结行数
                    ActiveWindow.SplitRow = 6 '设置冻结行数
                    ActiveWindow.FreezePanes = True
                    ActiveWindow.DisplayZeros = False '设置0值不显示
                End With
                .Close True
            End With
        End If
        MyName = Dir
    Loop
    Application.ScreenUpdating = True
End Sub
原文地址:https://www.cnblogs.com/bigmonk/p/12749984.html