View Single Post
Old 11-29-2009, 11:06 AM
Mike Rosenblum's Avatar
Mike Rosenblum Mike Rosenblum is offline
Microsoft Excel MVP

Forum Leader
* Guru *
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848

Hi XJ,

First, you need to be aware that the Range.RemoveDuplicates method is only available for Excel 2007 and above. If you need your program to work on Excel 2003 and below, then you should create your own routine to do this, such as sorting the rows and then deleting any duplicates.

When using the Range.RemoveDuplicates method, the Columns parameter is optional, and consists of an array of column numbers that tell the method which columns are to be considered when looking for duplicate data. If this parameter is omitted, then all columns are compared in each row.

For example, you could use the following to have the RemoveDuplicates method compare the first four columns:

MyRange2.RemoveDuplicates(Columns:= Array(1, 2, 3, 4), XlYesNoGuess.xlYes)
(I think that one of the reasons you might have been struggling with the above because you mispelled "Columns" as "Colunm".)

I hope this helps!

My Articles:
| Excel from .NET | Excel RibbonX using VBA | Excel from VB6 | CVErr in .NET | MVP |
Avatar by Lebb
Reply With Quote