Untitled
unknown
plain_text
a year ago
1.3 kB
5
Indexable
Private initialZoom As Integer Private Function IsMergedCell(ByVal rng As Range) As Boolean IsMergedCell = rng.MergeCells End Function Private Function IsBlankCell(ByVal rng As Range) As Boolean IsBlankCell = rng.Value = "" 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 ElseIf IsBlankCell(selectedCell) Then ActiveWindow.Zoom = 60 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 Sub
Editor is loading...