In this answer I suppose that your goal is not to lock the cells from editing,
but only to disable selecting the cells using the mouse. That is, user is still allowed to edit a cell, but she needs to first select it using Tab or Arrow buttons, and then she can edit it by pressing F2 or typing.
Add the following code to your Worksheet's code module:
Option Explicit
Private Declare PtrSafe Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
' The keyword PtrSafe is needed only if you are working on a Win64 platform
' Remove it if you are using Win32
Private lastSelection As Range
Private Sub Worksheet_Activate()
On Error Resume Next
Set lastSelection = Selection.Cells(1)
If Err.Number <> 0 Then Set lastSelection = Cells(1, 1)
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim e As Variant
For Each e In Array(vbKeyUp, vbKeyDown, vbKeyLeft, vbKeyRight, vbKeyTab, vbKeyReturn, vbKeyHome, vbKeyEnd, vbKeyPageDown, vbKeyPageUp)
If CBool(GetAsyncKeyState(e) And &H8000) Then 'You got here without using the mouse
Set lastSelection = Target
' do other stuff if needed
Exit Sub
End If
Next
' Selection was changed via mouse. Rollback
If lastSelection Is Nothing Then Set lastSelection = Cells(1, 1)
lastSelection.Activate
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
End Sub