Disable All Keyboard Keys Except Few

DrGenetix

New Member
Joined
Jul 20, 2005
Messages
4
Hi guys,

I am creating a monthly rota for a staff of 112. I want to place their duties as

M (morning)
E (evening)
N (night)

and so I do not want any other keys to work on the workbook so that I can enter data more fluently. Please tell me if it is possible. Secondly is it possible that after entering a value in the cell the next cell is selected automatically ?

Regards

Haider Ali
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Here's one way to do it [without disabling any keys] and advance to same row next column [if you want to advance to next row in same column, adjust following code as needed]:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Asc(Target.Value) = 69 Or Asc(Target.Value) = 77 Or Asc(Target.Value) = 78 Then
        ' to go to next row
        'Target.Offset(1, 0).Select
        ' to go to next column
        Target.Offset(0, 1).Select
    Else
        Application.EnableEvents = False
        Target.Value = ""
        Application.EnableEvents = True
        MsgBox "You must enter either M, E, or N", vbCritical, "Invalid Entry"
        Target.Select
    End If
    
End Sub

This code will only accept the capital letters M, E, or N....lower case m,e, n are rejected.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,280
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top