+ Reply to Thread
Results 1 to 14 of 14

haw to remove duplicates from an array

  1. #1
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    haw to remove duplicates from an array

    i have been googling the above and have not found a solution to my needs. all i need is to remove duplicates from an array. i searched this site but did not find a solution in the first few pages. here is my code:

    Please Login or Register  to view this content.
    and here is the functions that i am using:

    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.
    so when i print out the MyNames(0), it is a list of names that is 11 words long, and it contains multiple names. i thought that when i used the function "IsInArray" that that would prevent the duplicates from occurring but it doesn't. and when i use the removedupes function, it doesn't do anything. im sure that this is because i am making an error in my code. could someone point out to what i have done wrong?

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: haw to remove duplicates from an array

    Why not just use a Scripting.Dictionary?

  3. #3
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: haw to remove duplicates from an array

    one of the functions does just that, see below:

    Please Login or Register  to view this content.
    still working on this, might have an answer in a bit.

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: haw to remove duplicates from an array

    I was thinking more of using the dictionary in the original code, rather than in a function.
    Also that is not one of the functions you originally posted.

  5. #5
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: haw to remove duplicates from an array

    i have tried several functions, but it might be how i assemble the array that is causing the problem. give me a bit to experiment and i will post back my results.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: haw to remove duplicates from an array

    With the Function in post#3 try
    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: haw to remove duplicates from an array

    i have tried several functions and procedures to make this work but i still can't figure out what i am doing wrong.

    i have data in cells A3:14 to D3:D14. i need create a list or array that uses unique names (in col A) based on code in col C.

    so my range("A33") should contain 4 names (and not 11) that have text wrap enabled and are listed one line at a time (but all in once cell).

    Fluff, can you assist?

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: haw to remove duplicates from an array

    Can you supply a sample workbook, showing expected results.

  9. #9
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: haw to remove duplicates from an array

    here is the workbook. note that i am helping out user on this thread: https://www.excelforum.com/excel-pro...ml#post5157048

    the procedure named testsumifs3 is what created most of the data (rows 33 - 37). just need names to be in column A. also note that my arrays (myarray, myarray2, myarray3) needs to be dynamic. any help is great!
    Attached Files Attached Files

  10. #10
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: haw to remove duplicates from an array

    Thanks for that, I have replied direct to the other thread, as I was struggling to understand some of what you were doing.

  11. #11
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: haw to remove duplicates from an array

    can i ask you what i was doing wrong in trying to get the names in to column A?

    in particular, is the function isinarray. i thought that if it was false, it was safe to add to array but it doesn't work like i would have expected.
    Last edited by dmcgov; 07-18-2019 at 01:11 PM.

  12. #12
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: haw to remove duplicates from an array

    I'm assuming that you were trying to do that with this bit of code
    Please Login or Register  to view this content.
    and whilst I don't quite understand what you were doing, the part in blue will just add the same name into each element of the myNames array as the value in names(a) does not change during that inner loop

  13. #13
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: haw to remove duplicates from an array

    i guess my question is on this bit of code:

    Please Login or Register  to view this content.
    my understanding is that it examines the array, and if not found, then adds it. where am i going wrong?

  14. #14
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: haw to remove duplicates from an array

    Difficult to tell as that code does not exist in your workbook.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Non-Array formula to Remove Duplicates and Sort in Ascending Order
    By bjnockle in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-17-2018, 02:59 PM
  2. Replies: 9
    Last Post: 01-18-2018, 03:00 AM
  3. [SOLVED] Remove Duplicates Column Array Value From Cell
    By yoshi_5 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-25-2016, 02:18 AM
  4. Remove duplicates from array and count number of values
    By JDG94 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-05-2016, 02:02 PM
  5. [SOLVED] Remove duplicates and sort array
    By abousetta in forum Excel Programming / VBA / Macros
    Replies: 35
    Last Post: 10-11-2012, 10:22 AM
  6. Remove duplicates from 1 dimensional array in VBA
    By zaphodb2003 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-08-2010, 04:18 AM
  7. Remove duplicates from one dimensional array
    By asha3010 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-29-2010, 05:09 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1