I have 2 listboxes in a userform. The idea is that the user can select items in listbox1 and move them to listbox2. Once they click “commandbutton4”, the data from listbox2 is pasted into my worksheet in column E.
I would like to be able to avoid duplicate entries from listbox2 to the worksheet. I built the below code but it does not quite do what I want.
I would like the code to do this – if there is say 4 entries in listbox2, and 2 entries are already in the spreadsheet (duplicates) and 2 are original, I would the a message box to pop up & identify which of the entries in listbox2 are duplicates. It would also be good if the duplicates could be highlighted so its easier for the user to remove from the list. Once the duplicates are removed, the user clicks on “commandbutton4” again and the entries are transferred to the worksheet.
My current code does half the job - if there is 2 original entries followed by 2 duplicates in the listbox2, it notifies the user about the duplicate. However once the duplicate is removed, as the original entry is at the top of the list, when pressing the “commandbutton4”, it says the original is also a duplicate, and once I exit the userform it appears on my spreadsheet. Obviously I don’t want the code to identify a “duplicate” that is not yet on the worksheet.
Any help would be greatly appreciated
PS - I have taught myself VBA for all of 2 weeks - this code may be absolutely terrible
Bookmarks