Dim sw As Object = nothing Dim dw As Object = nothing Dim ss As Object = nothing Dim ds As Object = nothing Dim excel As Object = nothing Dim sheet As Object = nothing Dim xlYes as integer = 1 Dim xlNo as integer = 2 Try sw = GetWorkbook(Handle, Workbook) ss = GetWorksheet(Handle, Workbook, Worksheet) sw.Activate() ss.Activate() excel = ss.Application sheet = excel.ActiveSheet sheet.Range("A1:C100").RemoveDuplicates(Columns:={1,2}, Header:=xlNo) Success = True Catch e As Exception Success = False Message = e.Message Finally sw = Nothing ss = Nothing dw = Nothing ds = Nothing excel = Nothing sheet = Nothing End Try