+ Reply to Thread
Results 1 to 5 of 5

Trying to run a macro to sort and remove duplicates from entire sheet

  1. #1
    Registered User
    Join Date
    08-31-2009
    Location
    Edinburgh
    MS-Off Ver
    Excel 2007
    Posts
    2

    Trying to run a macro to sort and remove duplicates from entire sheet

    Hi, currently use this macro (see below) but occasionally I have more rows than 842. I could increase to 10000 and this would work but looking for a more automated macro that will automatically remove duplicates from all rows i.e. a macro that works out all rows.

    Sub copyTab()
    '
    ' copyTab Macro
    '

    '
    Cells.Select
    Selection.Copy
    Sheets("filtered_data").Select
    Range("A1").Select
    ActiveSheet.Paste
    Columns("A:A").Select
    Application.CutCopyMode = False
    ActiveSheet.Range("$A$1:$J$842").RemoveDuplicates Columns:=1, Header:=xlYes
    End Sub
    Last edited by sgmiller; 08-31-2009 at 01:38 PM.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Trying to run a macro to sort and remove duplicates from entire sheet

    Try

    Please Login or Register  to view this content.
    assuming that there are no intervening blank rows.
    Martin

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Trying to run a macro to sort and remove duplicates from entire sheet

    Hi SGMiller. Welcome. Be sure to read through the Forum Rules so you can use and follow them effectively. For instance, you'll need to edit that post above and put code tags around that code you used. (Like I did below...)

    I don't use Excel 2007, but in 2003 I use this technique to spot the last row of data (LR) and use it in the range instructions:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    08-31-2009
    Location
    Edinburgh
    MS-Off Ver
    Excel 2007
    Posts
    2

    Thumbs up Re: Trying to run a macro to sort and remove duplicates from entire sheet

    Quote Originally Posted by JBeaucaire View Post
    Hi SGMiller. Welcome. Be sure to read through the Forum Rules so you can use and follow them effectively. For instance, you'll need to edit that post above and put code tags around that code you used. (Like I did below...)

    I don't use Excel 2007, but in 2003 I use this technique to spot the last row of data (LR) and use it in the range instructions:
    Please Login or Register  to view this content.
    Hi this worked perfectly. Many thanks for you prompt reply.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Trying to run a macro to sort and remove duplicates from entire sheet

    Great! If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].


    (Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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