Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET Office Automation (http://www.xtremevbtalk.com/-net-office-automation/)
-   -   Removing Duplicates (http://www.xtremevbtalk.com/-net-office-automation/328616-removing-duplicates.html)

deepakrx8 04-02-2017 10:48 PM

Removing Duplicates
 
Edit by Moderator: Re: http://www.xtremevbtalk.com/-net-off...uplicates.html
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, _
Header:=Excel.XlYesNoGuess.xlYes)
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

Next
---------------------------------
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 "r.select" 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}


All times are GMT -6. The time now is 08:42 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.