CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2008
    Posts
    2

    Angry Remove Duplicates in Excel

    Hi. I've been trying to remove duplicates in Excel worksheet.
    So far, i've been trying to get something out of:

    Microsoft.Office.Interop.Excel.Range.RemoveDuplicates(object Columns, Microsoft.Office.Interop.Excel.XlYesNoGuess Header)

    which doesn't seem to have any explanation in MSDN nor anywhere i looked for. Well, it's pretty self-explanatory really, except the 1st parameter. I tried passing it an int array and casting it to object, but i am getting an exception. I can pass an int, like (object)1 for example, but then it takes in account just the 1st column and will remove all duplicates according to that.
    So for example, if i input this table:
    12 123 456
    ds fds
    12 123 456
    12 123 456
    54 123 33
    54 47 33

    this is what i am getting:

    12 123 456
    ds fds
    54 123 33

    And that's not i want to get. My last row should have stayed as well.
    That would be like an equivalent to the Excel function when we press "Remove duplicates" and have an option to select which columns should be taken into account.

    Thanks

  2. #2
    Join Date
    Jun 2008
    Posts
    2

    Resolved Re: Remove Duplicates in Excel

    I solved it. I just passed an int array casted to object.

  3. #3
    Join Date
    Jun 2010
    Posts
    4

    Re: Remove Duplicates in Excel

    can you explain how do you make the conection an remove the duplicates in more details pls

  4. #4
    Join Date
    May 2007
    Location
    Denmark
    Posts
    623

    Re: Remove Duplicates in Excel

    This thread i two years old! Please make a new thread if you need help.

    To answer the question: You can modify an Excel workbook using C# in a few ways, such as through COM Interop or an OLEDB Adapter.
    It's not a bug, it's a feature!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured