僅顯示指定區域,其餘隱藏,手動操作繁瑣。透過 VBA 巨集可一次性隱藏選取區域外的所有列與行。



Sub HiddenSurroundRange()
Dim CelFirst As Range, CelLast As Range
If Not Selection Is Nothing Then
With Selection
Set CelFirst = .Cells(1)
Set CelLast = .Cells(.Cells.Count)
End With
If CelFirst.Address <> "$A$1" Then
With Range([a1], CelFirst.Offset(IIf(CelFirst.Row = 1, 0, -1), IIf(CelFirst.Column = 1, 0, -1)))
If CelFirst.Row <> 1 Then .EntireRow.Hidden = True
If CelFirst.Column <> 1 Then .EntireColumn.Hidden = True
End With
End If
If CelLast.Address <> "$IV$65536" Then
With Range(CelLast.Offset(IIf(CelLast.Row = 65536, 0, 1), IIf(CelLast.Column = 256, 0, 1)), [IV65536])
If CelLast.Row <> 65536 Then .EntireRow.Hidden = True
If CelLast.Column <> 256 Then .EntireColumn.Hidden = True
End With
End If
End If
End Sub


WPS 預設未安裝 VBA 環境,需額外安裝。WPS Office 線上文件公測版可共享含巨集文件。開啟含巨集文件時請啟用巨集。