Forum Discussion
sgldjj
Feb 08, 2025Copper Contributor
RemoveDuplicates not removing all duplicates
I am using this line of code to remove duplicates from a column in Excel: Sheet2.Range("H1:H8").RemoveDuplicates Columns:=1, Header:=xlNo My test data is: test test one two three three just ...
Riny_van_Eekelen
Feb 08, 2025Platinum Contributor
H1:H8 contains 8 cells, whereas the last occurrence of "three" would be the ninth. So, just expand the range to H1:H9.
But perhaps better to avoid VBA altogether and format the list of words as a structured Excel table and then use the "Remove Duplicates" button on the Tables ribbon under Tools.