![]() |
error with data validation
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 |
error with data validation
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)" -----Original Message----- change the Formula1 to read Formula1:=A1 = Round(A1, 2) Mark D "Claude" wrote in message ... 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 . |
All times are GMT +1. The time now is 05:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com