Untitled

Anonymous
plain_text
09/07/2023 3:24 AM
1.0 KB
19
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)
    On Error GoTo GaExcel
    Dim xZoom As Integer
    xZoom = 60

    If Target.Validation.Type = xlValidateList Then
        xZoom = 150
    ElseIf IsMergedCell(Target) Or Not Intersect(Target, Me.UsedRange) Is Nothing Then
        xZoom = 150
    End If
    
GaExcel:
    ' 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 xZoom = 150 Then
        ActiveWindow.Zoom = xZoom
    Else
        ActiveWindow.Zoom = initialZoom
    End If
End Sub
Editor is loading...