I have an array of combinations called "Keys". I want to check if each combination exists in the column I, and if so, split the existing combination in 2 strings and add them as a pair in my dictionary "combiExist". My code throws a 457 error
Dim combiExist As Object
Set combiExist = CreateObject("Scripting.Dictionary")
For Each cle In keys
'If combination exists in my range
If Not .Range("I:I").Find(cle) Is Nothing Then
'Split string from 7th position, left part is the key, right part is the value
combiExist.Add Left(cle, 7), Right(cle, 7)
End If
Next
How can I solve this ?
On Error Resume Next. It means key already exists. That is why one uses a dictionary. Why are you using one.Existsmethod to check if a key exists before adding it. Returns a boolean.Right(cle, 7)will give you the rightmost 7 characters, no matter how long the string incleis. I recommend to usemid(cle, 8), that will give you the rest of your string in all caseskeys? It would be good to show that part, too. Then,Findneeds more parameters to be sure that previously it has not been used with something unappropriated. Are the keys you search for unique in that specific column? In fact, its first 7 digits... Anyhow,Findwill always return the first occurrence. Doescleall the time has 14 digits?