Hello, how do I change the below code so when I enter a value on column M via paste it will return a messagebox saying "invalid data"?
the below code works however it isn't limited to just column M. it happens to all cells
Private Sub Worksheet_Change(ByVal Target As Range)
Dim FindString As String
Dim Rng As Range
On Error Resume Next
FindString = Range("M2").Value
If Trim(FindString) <> "" Then
With Sheets("IDs").Range("A:A") 'searches all of column A
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Else
MsgBox "Invalid Data!" 'value not found
Target.Clear
End If
End With
End If
End Sub
Please help thank you