title: Application.OnKey Procedure error - Cannot run Macro
body: <p>I am working on a module which uses an onkey event to detect if backspace or delete is pressed, if it meets the criteria for the event, the corresponding cells will clear contents.</p>
  
  <p>I have a procedure to launch the corresponding sub, but I get an error 'the macro cannot be found'</p>
  
  <p>I have attached an image of the error and the code below, any suggestions?</p>
  
  <p><strong>Image of error</strong>
  <img src="https://i.stack.imgur.com/1NoKu.png" alt="enter image description here"></p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  If ActiveCell.Column = 2 Then
     Application.OnKey Key:="{DEL}", Procedure:="DeleteResources"
     Application.OnKey Key:="{BACKSPACE}", Procedure:="DeleteResources"
  End If
  End Sub
  
  Public Sub DeleteResources()
  ActiveCell.Offset(, 1).ClearContents
  ActiveCell.Offset(, 2).ClearContents
  ActiveCell.Offset(, 3).ClearContents
  End If
  End Sub
  </code></pre>