none
How to remove duplicate rows/data regardles array size RRS feed

  • Question

  • Trying to figure out in vb.net to write an addin that removs duplicates regardless of the array length.
    Tuesday, April 17, 2018 8:21 PM

Answers

  • Hello jbrotto,

    It seems that you want to use the Remove Duplicates function via Add-in in Excel, right?

    So you said "removs duplicates regardless of the array length", is that mean you want to remove duplicate row according to the whole columns? Only the entire row is duplicate, then you will delete the duplicate rows?

    If so, please try to refer to below code. If not, please detail your requirement so we could try to reproduce it.

    Dim xlApp As Excel.Application = Globals.ThisAddIn.Application
            Dim xlWorkSheet As Excel.Worksheet = xlApp.ActiveSheet
            Dim ColumnCount As Integer = xlWorkSheet.UsedRange.Columns.Count
            Dim arr(ColumnCount - 1) As Object
            For i = 1 To ColumnCount
                arr(i - 1) = i
            Next
            xlWorkSheet.UsedRange.RemoveDuplicates(arr, Microsoft.Office.Interop.Excel.XlYesNoGuess.xlNo)

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by jbrotto Thursday, July 19, 2018 7:39 PM
    Monday, April 23, 2018 10:37 AM

All replies

  • Hello jbrotto,

    What do you mean duplicates? Could you please detail your issue? What's the relationship of your requirement and office?

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 18, 2018 1:28 AM
  • I am looking for information how the use remove duplicates in the data tab. Also some explanation best practice on how to use it.
    Saturday, April 21, 2018 6:06 PM
  • Hello jbrotto,

    It seems that you want to use the Remove Duplicates function via Add-in in Excel, right?

    So you said "removs duplicates regardless of the array length", is that mean you want to remove duplicate row according to the whole columns? Only the entire row is duplicate, then you will delete the duplicate rows?

    If so, please try to refer to below code. If not, please detail your requirement so we could try to reproduce it.

    Dim xlApp As Excel.Application = Globals.ThisAddIn.Application
            Dim xlWorkSheet As Excel.Worksheet = xlApp.ActiveSheet
            Dim ColumnCount As Integer = xlWorkSheet.UsedRange.Columns.Count
            Dim arr(ColumnCount - 1) As Object
            For i = 1 To ColumnCount
                arr(i - 1) = i
            Next
            xlWorkSheet.UsedRange.RemoveDuplicates(arr, Microsoft.Office.Interop.Excel.XlYesNoGuess.xlNo)

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by jbrotto Thursday, July 19, 2018 7:39 PM
    Monday, April 23, 2018 10:37 AM