| 
                                                    
                                        
                    
                
 
                
        
| 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
 
 
 | 
 | 
        
快表帝国客服