hi. i need a vba code to prevent users from paste in to cell that have data validation list. i have this code. but this code not allow to select item from list or not allow to write in
--------------------------------------------------------------------------------------------
Mod Edit: Added code tag.
Code:
If HasValidation(Range("y19:bc48")) Then
Application.EnableEvents = True
Exit Sub
Else
Application.Undo
MsgBox "Error: You cannot paste data into these cells." & _
"Please use the drop-down to enter data instead.", vbCritical
End If
Private Function HasValidation(r) As Boolean
'Returns True if every cell in Range r uses Data Validation
On Error Resume Next
x = r.Validation.Type
If Err.Number = 0 Then HasValidation = True Else HasValidation = False
End Function
Mod Edit: Added code tag.
Last edited by a moderator: