+ Reply to Thread
Results 1 to 7 of 7

Problem with RemoveDuplicates method

  1. #1
    Forum Contributor Mayda89's Avatar
    Join Date
    09-13-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    192

    Problem with RemoveDuplicates method

    Hi everyone,

    I have written a code to remove duplicates from a given range, and the problem is, my code works without any problem in my Mac computer (excel 2011), but when I try to run this code on Windows (excel 2010), the remove duplicates method just does not remove the duplicates!!!
    The part of the code that doesn't work was:
    Please Login or Register  to view this content.
    Please note that there is no problem with the definition of the range.

    I know that the removeduplicates method has the two optional parameters 'columns' & 'header', which I omitted at first. I have omitted them because the default options for these paramaters suit my needs. After multiple trials, I have noticed that when I omit the 'columns' parameter in Excel 2010 in Windows, the removeduplicates method does not do anything! It does not even give an error! So then, I tried to accomplish the task by simply inputting the columns and header parameters, like this:
    Please Login or Register  to view this content.
    Note that colnumber is a variable, which is defined as an integer, and it is the first column of the range.

    When write a simple line of code like this in a new macro, the code works. However, when I run this code in the whole macro I wrote, I have an even more interesting problem, it runs smoothly the first time in the loop, than after that it keeps on generating the error "application defined or object defined error". The code as it is in the loop is below.
    Please Login or Register  to view this content.
    Note that the worksheet I am working on is not protected.

    Please help me, I have been searching all over the internet for weeks, and I couldn't find anything to this annoying problem!

    Gokalp

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Problem with RemoveDuplicates method

    For that last code try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor Mayda89's Avatar
    Join Date
    09-13-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    192

    Re: Problem with RemoveDuplicates method

    Hi Norie,
    Thanks for the rapid response
    Unortunately, your suggestion doesn't solve the problem

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Problem with RemoveDuplicates method

    Oops, forgot to change something.

    Which columns are you actually trying to remove duplicates from?

    Is this any better?
    Please Login or Register  to view this content.
    Last edited by Norie; 03-18-2013 at 12:22 PM.

  5. #5
    Forum Contributor Mayda89's Avatar
    Join Date
    09-13-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    192

    Re: Problem with RemoveDuplicates method

    Actually, I am indifferent, because if the values in the first column are the same, then the values in the second column will also be the same. Yet, for simplicity, I am telling Excel to remove the duplicates from the column referred to by the variable ColDrft.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Problem with RemoveDuplicates method

    Check the code I added.

  7. #7
    Forum Contributor Mayda89's Avatar
    Join Date
    09-13-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    192

    Re: Problem with RemoveDuplicates method

    Oh I got it!
    So I got the meaning of the columns parameter all wrong! The columns parameter should actually refer to the position of the column in the defined range, not the column number of the columns of interest!

    Dear Norie, I cannot thank you enough!!!!!!!
    Thank you very very much!!!!!!


    Take Care!
    Gokalp

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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