ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Validation error (https://www.excelbanter.com/excel-programming/439002-validation-error.html)

Hydra

Validation error
 
I'm trying to modify validation for adjacent celss on the fly depending on
the value of the previous cell. I've got this code but it is throwing an
error.

?????


If ActiveCell.Offset(0, -1).Value = "D" Then
'Range(Myaddress).Validation.Modify (xlValidateDate,
xlValidAlertInformation, _ xlBetween, ="1/1/2010", ="12/31/2020")

Endif

Hydra

Validation error
 
What I wound up with was:



If ActiveCell.Offset(0, -1).Value = "D" Then

With Range(Myaddress).Validation
.Delete
.Add Type:=xlValidateDate, _
AlertStyle:=xlValidAlertInformation, _
Operator:=xlBetween, _
Formula1:="1/1/2010", Formula2:="12/31/2020"
End With

Else

With Range(Myaddress).Offset(0, 1).Validation
.Delete
.Add Type:=xlValidateDate, _
AlertStyle:=xlValidAlertInformation, _
Operator:=xlBetween, _
Formula1:="1/1/2010", Formula2:="12/31/2020"
End With





"Hydra" wrote:

I'm trying to modify validation for adjacent celss on the fly depending on
the value of the previous cell. I've got this code but it is throwing an
error.

?????


If ActiveCell.Offset(0, -1).Value = "D" Then
'Range(Myaddress).Validation.Modify (xlValidateDate,
xlValidAlertInformation, _ xlBetween, ="1/1/2010", ="12/31/2020")

Endif



All times are GMT +1. The time now is 03:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com