Add in SwitchSheet: Quay lại các sheet đã xem trước đó bằng phím tắt

Liên hệ QC
Bạn thử cho tôi xem đoạn code bạn đặt phím tắt Alt + A thử xem
Dạ đây! anh xem giúp em ạ!
Mã:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Tac gia: Nguyen Huu Thang (huuthang_bd - giaiphapexcel.com)'
'http://www.giaiphapexcel.com/forum/showthread.php?81574    '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
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 Auto_Open()
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
 
Tôi nói code bạn đặt được phím tắt Alt + A chứ bạn làm không được thì đưa code này lên làm gì.
 
1. Máy tôi win 32 bit nên không biết khai báo thiếu biến sẽ lỗi trên win 64 bit.
2. Tôi viết dòng đó là có lý do, không thừa đâu. Bản tôi úp lên tôi sẽ không sửa. Bạn thích sửa thì bạn cứ sửa nhé.
Split("/Sheet1/", "/") khác với Split("Sheet1", "/") nhé. Kết quả không khác nhau do tôi đã có lệnh kiểm tra sự tồn tại của sheet bên dưới nhưng không lý do gì bắt máy tính làm việc nhiều hơn khi kết quả như nhau.
3. Về vấn đề password, tôi chẳng hiểu các bạn làm gì mà bảo password sai. Tôi sẽ úp bản không khóa lên nhưng các bạn cứ xem clip này xem tôi có nói sai password không.
[video=youtube;39r6pGj3Z8I]
Em dùng excel 2019 32b, khi load add in và dùng tổ hợp phím (Alt+Q) thì thấy hiện lên hình dưới mà không thể quay lại sheet trước đó, nhờ anh xem giúp.rt.png
 
Em dùng excel 2019 32b, khi load add in và dùng tổ hợp phím (Alt+Q) thì thấy hiện lên hình dưới mà không thể quay lại sheet trước đó, nhờ anh xem giúp.View attachment 234211
Các phiên bản sau này "Alt + q" là phím tắt "tell me what you want to do..." và không thể đặt phím tắt đè lên. Bạn có thể dùng tổ hợp phím tắt khác theo hướng dẫn dưới đây.
Bạn sử dụng file này. Nếu muốn thay đổi phím tắt thì thay đổi các dòng khai báo đầu trong module M01 theo hướng dẫn được ghi chú trong code.
 
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 Auto_Open()
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
 
Em dùng office 2016 nhưng không sử dụng Add in được, đều báo lỗi
Thử tất cả các file từ file dành cho 64 bit, tới file dành cho Office 2016 cũng không được

Sau hơn 8 trang trao dổi, Anh/Chị có thể gửi lại file hoạt động tốt cho Office 2016 không ạ?
 
Tôi nghĩ đa số những người dùng máy tính thường xuyên sử dụng phím tắt Alt + Tab để mở lại cửa sổ gần nhất vì nó rất tiện lợi. Tuy nhiên, trên Excel khi ta muốn xem lại sheet vừa xem thì phải tìm và chọn. Đối với những file có nhiều sheet thì rất mất thời gian. Vì vậy, tôi tạo ra Addin này.

Công dụng duy nhất: Mở lại các Sheet đã mở gần nhất bằng phím tắt Alt + q (tôi chọn phím q vì phím q gần với phím tab, các bạn có thể sửa lại trong code)

Hy vọng Addin này sẽ giúp tiết kiệm thời gian cho những người thường xuyên làm việc trên Excel.
Bạn ơi, mình rất mong bạn hỗ trợ mình cai cái switchsheet nay, minh cài hoài mà ko thấy xài được, giúp mình với
 
Web KT
Back
Top Bottom