Untitled
unknown
plain_text
2 years ago
1.1 kB
13
Indexable
Private initialZoom As Integer
Private Function IsMergedCell(ByVal rng As Range) As Boolean
IsMergedCell = rng.MergeCells
End Function
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim selectedCell As Range
Set selectedCell = Target.Cells(1)
' Kiểm tra nếu chưa lưu kích thước ban đầu
If initialZoom = 0 Then
initialZoom = ActiveWindow.Zoom
End If
If IsMergedCell(selectedCell) Or Not Intersect(selectedCell, Me.UsedRange) Is Nothing Then
ActiveWindow.Zoom = 150
Else
ActiveWindow.Zoom = initialZoom
End If
' Kiểm tra nếu không có ô nào được chọn
If Target.Cells.Count = 1 Then
If Not Intersect(Target, Me.UsedRange) Is Nothing Then
' Ô được chọn nằm trong vùng dữ liệu của bảng
ActiveWindow.Zoom = 100
Else
' Ô được chọn không nằm trong vùng dữ liệu của bảng
ActiveWindow.Zoom = initialZoom
End If
End If
End SubEditor is loading...