I have a excel that im adding a data validation.
When I use the Data Validation process trough the excel function it works fine:
Custom Formula : =IF(AND(M7>=DATE(2015;1;1);M7<=D7);TRUE;FALSE)
But when i use VBA code to add that data validation the following error occurs:
Run-Time error '1004':
Application-defined or object-defined error
VBA:
Range("M7:M" & (6 + 15)).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=IF(AND(M7>=DATE(2015;1;1);M7<=D7);TRUE;FALSE)"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = False
.ShowError = True
End With
What im doing wrong ?
Thank you for the help.