Re: Data Validation - Why does it not work when pasting valu
Summing up the discussion so far, either you need to make sure that only Paste-Special-Values will be used, OR you can put references to a separate paste area and validate the referring cells.
OK that's one part of the problem solved; but one would ideally like to use Excel to set up the validation rules, and use VBA as sparingly as possible. So...
Let's define a name, "ValRange", that points to the cells that need to be validated. Then...
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
Debug.Print Target.Address
valid = True
For Each c In Range("ValRange").Cells
valid = valid And c.Validation.Value
Next c
Debug.Print valid
If Not valid Then
MsgBox "At least one cell is not valid"
Application.Undo
Else
End If
Application.CutCopyMode = False
End Sub