I'm using a function I wrote called 'Contains' to determine if entries in a column of data match a dictionary of 'acceptable' values that are predetermined.
Sub Validate_Data()
Dim My_Dictionary As Variant
My_Dictionary = Array("Entry1", "Entry2", "Entry3")
Dim Destination As Range
Set Destination = Range("C2:C10")
For Each cell In Destination
cell.FormulaR1C1 = Contains(My_Dictionary, cell)
Next cell
End Sub
This code works perfectly fine when I specify the elements of my array, as above. However, when I try to create an array from a range of data, as per this post, my function Contains no longer works
Sub Validate_Data()
Dim My_Dictionary As Variant
My_Dictionary = Range("A1:A3").Value
Dim Destination As Range
Set Destination = Range("C2:C10")
For Each cell In Destination
cell.FormulaR1C1 = Contains(My_Dictionary, cell)
Next cell
End Sub
Perhaps it is being saved as a different data type in one version as opposed to the other? I can't figure why the first code works and the second does not, and I would rather be able to read the array from a sheet than specify each element in my code (it is much longer than three elements).