• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Remove Duplicates from Excel Table

rumshar

Member
Hi All,
Can you please help me with VBA code to remove duplicates for an excel table. I don't wan't to refer table by its name. Currently I am using following code which is not working.

Code:
ActiveSheet.ListObjects(1).RemoveDuplicates Columns:=1, Header:=xlYes
 
I'd be using something like:

Code:
  ActiveSheet.Range("$A$1:$H$100").RemoveDuplicates Columns:=1, Header:=xlYes
 
Hi ,

Since the RemoveDuplicates method is applicable to a Range , you may need to use this :

ActiveSheet.ListObjects(1).DataBodyRange.RemoveDuplicates Columns:=1, Header:=xlYes

Narayan
Thanks Narayan. I didn't think that way earlier. Thanks once again.
 
I'd be using something like:

Code:
  ActiveSheet.Range("$A$1:$H$100").RemoveDuplicates Columns:=1, Header:=xlYes
Thanks Hui,
But I feel the code you have given suits well for normal excel range and not for excel tables. Anyways I got the solution from Narayan. Thanks for taking your time and trying to help me out. You guys are awesome.
 
Back
Top