cancel
Showing results for 
Search instead for 
Did you mean: 

RemoveDuplicates VB code stage

DerekTurner
Level 3
Hello everyone,

I have found a few places in the many forums available where there is some mention of using this VB code in a code stage to remove duplicate lines within an Excel file.  This code below works perfectly fine when I only pass it one column to check, but I cannot figure out how to pass multiple columns to be checked.

sheet.Range("A1:E100").RemoveDuplicates(Columns:=1, Header:=1) works great.

I have tried using the following code using curly brackets which I had read was how you should represent an array, but I get the error "Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))"

sheet.Range("A1:E100").RemoveDuplicates(Columns:={1,2}, Header:=1)

The following gives me an error of Exception from HRESULT: 0x800A03EC
sheet.Range("A1:E100").RemoveDuplicates(Columns:="1,2", Header:=1)

I know there are other ways to go this via macros, spying Excel etc, but I am trying to build up my own Excel VBO to supplement what is currently missing from the existing one.

Does anyone have any experience with how to fix this?  Any help or thoughts would be greatly appreciated.

------------------------------
Derek Turner
Applications Advisor
Celestica
America/Toronto
------------------------------
0 REPLIES 0