I have code in Python that I'm trying to convert to VBA.
List = []
For x in range:
if x not in list:
list.append(x)
I would create an empty list, the Python code would loop through my desired data (defined here as "range") then check if the element was in the list, and if it wasn't, add it.
I am trying to do the same in VBA. It needs to go down one column, and add unique elements in that column to a VBA list.
Based on searching I have this:
Dim list() As Variant
For n = 1 To end
If list.Contains(Cells(n,1).value) Then
list(n) = Cells(n,1).value
n= n+1
When I run this code, I get an error where it highlights the "list" in
If list.Contains(Cells(n,1).value) Then
and says
"Invalid qualifier".
I tried changing it to
if list.Contains(Cells(n,1).value) = True
to add a qualifier.
All I need to do is create a list of strings. Is there a better way to do this in VBA?