user9272092
user9272092

Reputation:

How to prevent the input of a specfic value into a cell

I'm trying to prevent the input of a specific value (text saying "latest") in a column but the code I've got doesn't seem to be functioning, any help would be appreciated, thanks.

Private Sub RevisionInput()
    Dim Revision As Range
    Dim Revisioncell As Range
    Set Revision = Range("M3:M500")
    For Each Revisioncell In Revision
    If Revisioncell Like "Latest" Or Revsioncell Like "LATEST" Or Revisioncell Like "latest" Then


MsgBox "Please input correct revision or if one is not available," & _
" Please type 'To be confirmed'"
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True

Else
End Sub

Upvotes: 0

Views: 290

Answers (1)

Dan
Dan

Reputation: 45751

You can do this without VBA. Under the Data tab on the ribbon chose Data Validation, then choose custom from the drop down and set the formula to (replace M3 with the first cell in your selection):

=M3<>"latest"

Upvotes: 2

Related Questions