View Single Post
Old 04-02-2017, 10:48 PM
deepakrx8 deepakrx8 is offline
Join Date: Apr 2017
Posts: 1
Default Removing Duplicates

Edit by Moderator: Re: Removing Duplicates
Hi Guru,

Could you please show how to pass in a dynamically populated array of object containing integers, in VB.NET?

range.RemoveDuplicates( _
Columns:=arr, _
Where arr is an array that contains integers which are populated dynamically.

Here is my attempt
Dynamically Creating the Array of Object containing integers.

Dim a() As Object
Dim range_array As Integer = (End_col - Start_col) + 1
'Start_col and End_col are passed in to give the starting and ending of the range.

ReDim a(range_array)
Dim i As Integer
For i = 0 To range_array
a(i) = i + 1

dim cd() as Object
'Version 1
' sheet is an object referring to the active sheet.

r = sheet.Range(Start_Cell &":"& End_Cell)
t = r.RemoveDuplicates columns:=(a) ' Version 1 Method1
t = r.RemoveDuplicates (columns:=(a)) ' Version 1 Method2

'Version 2
'cd = New Object(){1, 2, 3, 4}
't = r.RemoveDuplicates(cd)
t = r.RemoveDuplicates


Tried both Version 1 and Version 2. Not seeing any change.

I was able to perform a "" using the range object and perform color changes on the range, however, when using the range object with RemoveDuplicates and the array passed, we are not getting the desired effect.

However, your method of passing the array works fine .

r.removeduplicates Columns:=New Object() {1, 2, 3, 4}

Last edited by Cerian Knight; 04-11-2017 at 01:57 PM.
Reply With Quote