有另一位網友JOHN的程式,提供您參考:
Public filterArray(), hidRowArray(), hidColArray() As Variant
Public condArray(1 To 3)
Sub mcCondLog()
Set lastC = Range("A1", ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell))
i = 0
Erase hidRowArray
Erase hidColArray
For Each c In lastC.Rows
If c.Hidden Then
ReDim Preserve hidRowArray(1 To i + 1)
hidRowArray(i + 1) = c.Row
i = i + 1
End If
Next c
i = 0
For Each c In lastC.Columns
If c.Hidden Then
ReDim Preserve hidColArray(1 To i + 1)
hidColArray(i + 1) = c.Column
i = i + 1
End If
Next c
With ActiveWindow
condArray(1) = .SplitColumn
condArray(2) = .SplitRow
condArray(3) = .Zoom
End With
End Sub
Sub mcRestorecCond()
With Range("A1", ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell))
.Rows.Hidden = False
.Columns.Hidden = False
End With
For i = 1 To UBound(hidRowArray())
If Not IsEmpty(hidRowArray(i)) Then Rows(hidRowArray(i)).Hidden = True
Next i
For i = 1 To UBound(hidColArray())
If Not IsEmpty(hidColArray(i)) Then Columns(hidColArray(i)).Hidden = True
Next i
With ActiveWindow
.SplitColumn = condArray(1)
.SplitRow = condArray(2)
.Zoom = condArray(3)
End With
End Sub
執行mcCondLog: 記錄目前的 隱藏欄/隱藏列/顯示比例/分割視窗條件
執行mcRestorecCond:恢復 隱藏欄/隱藏列/顯示比例/分割視窗條件
至於「凍結窗格」功能,因為VBA抓不到目前凍結的分配位置,因此無法作記錄與恢復。