Hi, I want to apply the same data validation to a range of cells ("F8:F51") on worksheet"B". This validation is based on the value in cell "S3" also on worksheet"B" which is populated from a formula based on the value from a range "Unit" in worksheet"A". So for example if range "Unit" on worksheet "A" equals "Yes", then cell S3 mirrors it and also equals "Yes". I need range ("F8:F51") on worksheet "B" to validate a list based off of "Yes". I also want it to clear the validation in case the wrong data is input or there is no data in cell "S3". Thanks for your help. The code I started on is below... The code does not want to work at all....I think it has something to do with cell S3 on worksheet"B" being populated via a formula.
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$S$3" Then
If Target.Value = "Yes" Then
With Range("F8:F51").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=EO2_SubP"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ElseIf Target.Value = "No" Then
With Range("F8:F51").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=EG2_SubP"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ElseIf Target.Value = "Maybe" Then
With Range("F8").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=EO3_SubP"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End If
End If
End Sub