Option Explicit
Public Const CtrlKey As Long = 17, AltKey As Long = 18
Public Const AltOrCtrl As Long = AltKey 'CtrlKey neu dung phim Ctrl - AltKey neu dung phim Alt
Public Const Key As String = "a" 'Thay doi theo nhu cau su dung
Public App As clsExcelApp
Private Sub Aut
pen()
Application.OnKey IIf(AltOrCtrl = AltKey, "^", "%") & "{" & Key & "}", "SwitchSheet"
Set App = New clsExcelApp
App.Wrap Application
End Sub
Private Sub Auto_Close()
Application.OnKey IIf(AltOrCtrl = AltKey, "^", "%") & "{" & Key & "}"
Set App = Nothing
End Sub
Private Sub SwitchSheet()
On Error Resume Next
Dim i As Long
For i = 0 To Frm_SheetsInfo.SwitchSheetLB.ListCount - 1
If Frm_SheetsInfo.SwitchSheetLB.List(i, 0) = ActiveWorkbook.Name Then
Dim j As Long, Array_Ordinal
If InStr(1, Frm_SheetsInfo.SwitchSheetLB.List(i, 1) & "/", ActiveSheet.Name & "/", vbTextCompare) <> 1 Then
Frm_SheetsInfo.SwitchSheetLB.List(i, 1) = Frm_SwitchSheet.Get_Sheets_Ordinal(ActiveWorkbook, Frm_SheetsInfo.SwitchSheetLB.List(i, 1))
End If
Array_Ordinal = Split(Frm_SheetsInfo.SwitchSheetLB.List(i, 1), "/")
For j = LBound(Array_Ordinal, 1) To UBound(Array_Ordinal, 1)
If ActiveWorkbook.Sheets(Array_Ordinal(j)) Is Nothing Then
GoTo Next_j
ElseIf ActiveWorkbook.Sheets(Array_Ordinal(j)).Visible = xlSheetVisible Then
Frm_SwitchSheet.LB_Sheets.AddItem Array_Ordinal(j)
End If
Next_j:
Next
If Frm_SwitchSheet.LB_Sheets.ListCount > 1 Then
Frm_SwitchSheet.LB_Sheets.ListIndex = 1
If Frm_SwitchSheet.LB_Sheets.ListCount < 12 Then
Frm_SwitchSheet.LB_Sheets.Height = 2 + Frm_SwitchSheet.LB_Sheets.ListCount * 10
Frm_SwitchSheet.Height = 21.75 + Frm_SwitchSheet.LB_Sheets.ListCount * 10
End If
Frm_SwitchSheet.Show
Else
Unload Frm_SwitchSheet
Frm_SwitchSheet.LB_Sheets.ListIndex = j
If Frm_SwitchSheet.LB_Sheets.ListCount > 1 Then
If Frm_SwitchSheet.LB_Sheets.ListCount < 12 Then
Frm_SwitchSheet.LB_Sheets.Height = 2 + Frm_SwitchSheet.LB_Sheets.ListCount * 10
Frm_SwitchSheet.Height = 21.75 + Frm_SwitchSheet.LB_Sheets.ListCount * 10
End If
Frm_SwitchSheet.Show
Else
Unload Frm_SwitchSheet
End If
End If
Exit Sub
End If
Next
End Sub