Excel VBA - Loop for populating ComboBox that doesn't add duplicates -


I am populating a combo box with user on the loop, it adds all the "names" to the first column of the table , Which is the same "type" in the second column

I do not want to go into detail, but it is possible that the same "name" happens many times, I do not want to loop to add those duplicate values .

I have found some solutions on other forums, but those people have seen me old and I think it should be easy solution.

Can anyone help me move forward with it?

This is populating loop (this "old" solution is like a 30+ sentence code, I do not think I need it)

:

  with resources. List objects ("Table 3") for X = 2. LISTRO.Count + 1 if range (x, 2) = cType then 'cbname is combobox cbn.m.editime  

Try it out:

Object Object Object Object Set as Ozz = Object (" Scripting .addition ") with resource socket. List objects ("Table 3") for X = 2. ListReo.Count + 1 if the range (x, 2) = cType then 'If the name is not yet present in the object of the object, then add a name to the listbox and dictionary object if isEmpty (obj.Item. (Range (x, 1) & Amp; "")) then 'cbname is cambodia cbn.editime. Range (X, 1) Obj.Item (.range (x, 1) & amp; "") = .henge (x, 1) end if end, then with next x end

The dictionary object allows you to use the name as a key. If the key does not exist, then it adds the name list to the box and adds the key next time it comes across the same name, that key already exists, so it can move to the next line.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -