error with data validation

  • Thread starter Thread starter Claude
  • Start date Start date
C

Claude

Hi all,
I have a strange problem: when I set the data validation
manually on a specific cell, this works without problems.
However, when I record the macro and try to execute the
code, I get an "application or object defined error" (on
the .Add bit).
Is there anything wrong with the following code?

Sub Macro7()

With Selection.Validation
.Delete
.Add Type:=xlValidateCustom,
AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=A1=round(A1;2)"
.IgnoreBlank = False
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = "Input error"
.InputMessage = ""
.ErrorMessage = "Please enter amounts rounded to
not more than 2 decimals!"
.ShowInput = False
.ShowError = True
End With
End Sub
 
Thanks Mark, you set me on the right track:
The recorder has recorded a ";" but the correct syntax
is ","
Both the following now work:
Formula1:="=a1=round(a1,2)"
Formula1:="A1=Round(A1, 2)"
 
Back
Top