Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6370333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:55:02+00:00 2026-05-25T00:55:02+00:00

Well the question is, I have got a column, for example column Y has

  • 0

Well the question is, I have got a column, for example column Y has many entries in it, nearly 40,000 and It increases everyweek. The thing is I have to check for duplicates in Y column and delete the entire row. Thus, Y column should have only unique entries.

Suppose I have 3,000 entries and after 1 week, i’ll have about 3,500 entries. Now I have to check these newly added 500 columnn values not the 3,500 with the old + the new i.e 3,500 entries and delete the duplicated row. The old 3,000 shouldn’t be deleted or changed. I have found macros but they do the trick for the entire column. I would like to filter the new 500 values.

 Cells(2, "Q").Formula = "=COUNTIF(P$1:P1,P2)=0"   'I have used these formula 
 Range("Q2").Copy Destination:=Range("Q3:Q40109")  'it gives false for the duplicate values

I know we have to use countif for the duplicate entries. But what Iam doing is applying the formula and then search for false entries and then delete it. I belive applying formula and finding false and then deleting its little bit time consuming.

Sub DeleteDups() 
Dim x               As Long 
Dim LastRow         As Long 
LastRow = Range("A65536").End(xlUp).Row 
For x = LastRow To 1 Step -1 
    If Application.WorksheetFunction.CountIf(Range("A1:A" & x), Range("A" & x).Text) > 1 Then 
        Range("A" & x).EntireRow.Delete 
    End If 
Next x   
End Sub 

This is what I found on google but i dont know where the error is. It is deleting all the columns if i set

For x = LastRow To 1 Step -1 
For x = LastRow to step 3000 ' It is deleting all 500 columns but if it is -1 working fine

Any modifications need to be done for these function? or sugest me any good function that helps me. Check for the duplicate values of a selected column range from the entire column. I mean check 500 entires column values with the 3500 column entry values and delete the duplicates in 500 entries

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:55:02+00:00Added an answer on May 25, 2026 at 12:55 am

    This should be rather simple. You need to create 1 cell somewhere in your file that you will write the cell count for column Y each week after removing all dupes.

    For example, say week1 you remove dupes and you are left with a range of Y1:Y100. Your function will put “100” somewhere in your file to reference.

    Next week, your function will start looking from dupes from (cell with ref number) + 1, so Y:101 to end of column. After removing dupes, the function changes the ref cell to the new count.

    Here is the code:

    Sub RemoveNewDupes()
    
    'Initialize for first time running this
    If Len(Range("A1").Value) = 0 Then
        Range("A1").Value = Range("Y" & Rows.count).End(xlUp).row
    End If
    
    If Range("A1").Value = 1 Then Range("A1").Value = 0
    
    'Goodbye dupes!
    ActiveSheet.Range("Y" & Range("A1").Value + 1 & ":Y" & _
    Range("Y" & Rows.count).End(xlUp).row).RemoveDuplicates Columns:=1, Header:=xlNo
    
    'Re-initialize the count for next time
    Range("A1").Value = Range("Y" & Rows.count).End(xlUp).row
    
    End Sub
    

    *sorry no idea why auto-syntax highlighting makes this hard to read

    Update:

    Here is a way to do it in Excel 2003. The trick is to loop backwards through the column so that the loop isn’t destroyed when you delete a row. I use a dictionary (which I’m famous for over-using) since it allows you to check easily for dupes.

    Sub RemoveNewDupes()
    
    Dim lastRow As Long
    Dim dict As Object
    Set dict = CreateObject("scripting.dictionary")
    
    If Len(Range("A1").Value) = 0 Then
        Range("A1").Value = 1
    End If
    
    lastRow = Range("Y" & Rows.count).End(xlUp).row
    
    On Error Resume Next
    For i = lastRow To Range("A1").Value Step -1
        If dict.exists(Range("Y" & i).Value) = True Then
            Range("Y" & i).EntireRow.Delete
        End If
        dict.Add Range("Y" & i).Value, 1
    Next
    
    Range("A1").Value = Range("Y" & Rows.count).End(xlUp).row
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As well as my question Removing MKMapView Annotations causes leaks. I have discovered that
The question seems pretty well formulated I have a virtual machine which implements only
Well, I have a simple question, at least I hope its simple. I was
I have two tables (well, two relevant for this question) : Bets (holds the
Well, the question is kinda simple. I have a object defined as: public class
Ok another WPF question, well I guess this is just general .NET. I have
I have asked this question on twitter as well the #clojure IRC channel, yet
I have got a question regarding suprepositories. Our project is set up like this:
I aint sure if I have asked this question in other threads as well
Disclaimer: I have looked through this question and this question but they both got

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.