Ctrl PgUp

%3CLINGO-SUB%20id%3D%22lingo-sub-1435192%22%20slang%3D%22en-US%22%3ECtrl%20PgUp%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1435192%22%20slang%3D%22en-US%22%3E%3CP%3EIs%20it%20possible%20to%20disable%20the%20Ctrl%20%2B%20PgUp%2FDn%20to%20switch%20sheets%20in%20an%20Excel%20workbook.%20I%20would%20be%20grateful%20for%20any%20advice%20on%20this%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1435192%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
New Contributor

Is it possible to disable the Ctrl + PgUp/Dn to switch sheets in an Excel workbook. I would be grateful for any advice on this

2 Replies
Highlighted

@PTCexceltools I believe you can achieve this using Excel VBA.

 

But you should be careful, when working with VBA.

 

Place the below code in your workbook module and see if it accomplishes what you are after.

 

To easily access your workbook module.

Hold the Alt key, and press the F11 key, to open the Visual Basic Editor, In the Project Explorer, find your workbook, and open the list of Microsoft Excel Objects, Right-click on the ThisWorkbook object, and choose View Code, Where the cursor is flashing, choose Edit | Paste, Press Alt+Q to return to the worksheet.

 

Private Sub Workbook_Open()
Application.OnKey "^{PGUP}", ""
Application.OnKey "^{PGDN}", ""
End Sub

 

Private Sub Workbook_Activate()
Application.OnKey "^{PGUP}", ""
Application.OnKey "^{PGDN}", ""
End Sub

 

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
Application.OnKey "^{PGUP}", ""
Application.OnKey "^{PGDN}", ""
End Sub

 

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnKey "^{PGUP}"
Application.OnKey "^{PGDN}"
End Sub

 

Private Sub Workbook_Deactivate()
Application.OnKey "^{PGUP}"
Application.OnKey "^{PGDN}"
End Sub

 

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
Application.OnKey "^{PGUP}"
Application.OnKey "^{PGDN}"
End Sub

Highlighted
Thanks for that I'll give that a go. For now I had a work around by hiding all sheets except the active one. It worked but I think your method will be better.. thanks again