Ctrl PgUp

Copper 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

@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

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