I am trying to get a data validation using vba. I can not seem to get the below code correct. I have posted part of the code below. I am wanting use the Match function to look at the Target Value. I am having trouble on this line "CHOOSE(MATCH(Target.Value,Categories,0),Column1,Column2)" The code language on Target.Value reads an error.
An example would be if cell A1 reads the word Red then add the data validation list Column1. Red is the first index in the Categories list.
With Target.Offset(0, 1).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=CHOOSE(MATCH(Target.Value,Categories,0),Column1,Column2)"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = "Cell Validated"
.InputMessage = ""
.ErrorMessage = "Cell validated.Select from dropdown list."
.ShowInput = True
.ShowError = True
End With
Bookmarks