Cell Input Monitoring

  • Thread starter Thread starter parteegolfer
  • Start date Start date
P

parteegolfer

I am looking to only allow an "X" be entered in Columns H9:H400,I9:I400
and J9:J400. If anything else is inserted in any of these cells a
Message box will pop up stating only an "X" can be entered in this
cell.

Any Ideas?

Thanks in advance!:)
 
You can use the Worksheet_Change event procedure. In the VBA editor, view
the project explorer and double-click on the worksheet you are using. Then
in the code pane type this code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim TestCell As Range, Invalid As Boolean
If Not (Intersect(Target, Range("H9:J400")) Is Nothing) Then
For Each TestCell In Target.Cells
Invalid = Invalid Or TestCell.Value <> "X"
Next TestCell
End If
If Invalid Then
MsgBox "You must enter 'X' here"
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
End If
End Sub
 
Tried this code and nothing happened when I entered something other than
an "x" in any of the cells to be monitored. Any suggestions?
 
Back
Top