+ Reply to Thread
Results 1 to 12 of 12

Formula for Duplicate prevention

  1. #1
    Registered User
    Join Date
    07-22-2014
    Location
    singapore
    MS-Off Ver
    2013
    Posts
    5

    Formula for Duplicate prevention

    Hi All,
    I'm a newbie to this forum.

    I need some excel formula to prevent duplicate cells in my excel file.

    Case: I have one excel sheet with one column containing certain cell occupied with data (Eg: A01 to A30), Now i'm try to paste some more data in the consecutive cells (Eg: A31 to A40). The data i'm pasted second (Eg: A31 to A40) may contain some data from first pasted data(Eg: A01 to A30). I need to remove the duplicates. In this case after pasting 2 datas i can remove duplicates. But i want to prevent from pasting of duplicate data..i.e. while pasting the second set of data, a pop window should appear and tell me "these data are already present" etc..

    could any one help me regarding this?

    Thanks in Advance.

    SHUN S

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,049

    Re: Formula for Duplicate prevention

    Hi and welcome to the forum

    You could use a helper column (column B, for instance), and then use the COUNTIF() function. You said your data starts in A1, so in B1, put this and copy down...

    =IF(COUNTIF($A$1:A1,A1)>1,"Duplicate","")

    Another way to remove duplicates is with excel's built-in Remove Duplicates button found under Data/Data Tools/Remove duplicates (save your file before you try this so that if you dont like the results, you can reload the file)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Re: Formula for Duplicate prevention

    Hi Shun S,
    Welcome to Excel Forum.

    To answer your query, unfortunately there is no built-in functionality in Excel that will check immediately pasted data with previously existing data and provide such a pop-up if duplicates exist. The only option is to remove duplicates after pasting (which you are already aware of).

    However, what you desire maybe possible with VBA. How comfortable are you with VBA?
    If you are aware of Worksheet_Change event; then you can create a code that will run when you paste the data 2nd time around; and check those values against the existing data to confirm whether or not there are any duplicates.

    Try searching for the said event and look at some examples of how it can be used. Also, please share a copy of your workbook - showing some sample data and what you desire - makes it easier for forum members to assist you.
    Good luck

  4. #4
    Valued Forum Contributor Saarang84's Avatar
    Join Date
    02-19-2009
    Location
    Chennai, India
    MS-Off Ver
    XL 2003 to 2010
    Posts
    812

    Re: Formula for Duplicate prevention

    Hi,

    Welcome to the Forum.

    It seems you need a conditional formatting formula in the appropriate column. As per your example, in column A, assuming you have 10000 rows of data, then you need to apply the below formula in conditional formatting and use some color for highlighting the duplicates :
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If my assistance has helped, there is a reputation icon * on the left hand corner below the post - you can show your appreciation to the user who has helped in resolving your requirement.

    If your requirement has been solved please mark your thread as Solved.
    In the menu bar above the very first post, select Thread Tools, then select "Mark this thread as Solved".

    Kindly use [FORMULA] or [CODE] tags when posting your code.

    Regards,
    Sarang

  5. #5
    Forum Contributor
    Join Date
    03-11-2014
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    379

    Re: Formula for Duplicate prevention

    Hi Shun S,

    Please check the attached file for Duplicate Prevention.

    In column A unique numbers are entered in cell A1:A30. When you enter the duplicate number in A31:A40 you will get a message as per your requirement by using Data Validation.

    Kindly go through & update if any further assistance is required.

    Regards,
    Ashish Mehra

  6. #6
    Registered User
    Join Date
    07-22-2014
    Location
    singapore
    MS-Off Ver
    2013
    Posts
    5

    Re: Formula for Duplicate prevention

    Hi Mehra,
    Thanks u very much 4 yr fast reply.

    I need some more clarifications 4m u,
    Yr file works fine only when the values are entered one by one.. For my case i will just copy and pasting the bunch of data, At that time it does not work out.
    Could u plz xplain me how come pink color cells are highlighted (When i try for myself in separate sheet. it doesn't works).

    Thanks 4 yr time and effort.

    SHUN

  7. #7
    Registered User
    Join Date
    07-22-2014
    Location
    singapore
    MS-Off Ver
    2013
    Posts
    5

    Re: Formula for Duplicate prevention

    Hi jewelsharma,
    Thanks 4 yr kind reply.

    I'm new to VBA..I have heard that people will be doing lot of automation in VBA.
    If possible could u pls get me code 4 this.

    THanks,
    SHUN S

  8. #8
    Registered User
    Join Date
    07-22-2014
    Location
    singapore
    MS-Off Ver
    2013
    Posts
    5

    Re: Formula for Duplicate prevention

    Hi All,
    Could any one provide me solution for this case?

    Thanks in Advance.

    SHUN S

  9. #9
    Valued Forum Contributor Saarang84's Avatar
    Join Date
    02-19-2009
    Location
    Chennai, India
    MS-Off Ver
    XL 2003 to 2010
    Posts
    812

    Re: Formula for Duplicate prevention

    Hi,

    My formula in post #4, can be used as an conditional formatting formula. When applied, this highlights the duplicates pasted into a column in the color that you specify in the conditional formatting. Refer attached workbook, I've used Red color. Once the data is pasted, the duplicates will be highlighted and can be removed manually later.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    07-22-2014
    Location
    singapore
    MS-Off Ver
    2013
    Posts
    5

    Re: Formula for Duplicate prevention

    Hi Saarang84,
    Thanks 4 yr effort and time.

    I think it would help me a lot.

    Kindly reveal the formula and process behind the RED highlight.

    Thanks and regards,
    SHUN


    Quote Originally Posted by Saarang84 View Post
    Hi,

    My formula in post #4, can be used as an conditional formatting formula. When applied, this highlights the duplicates pasted into a column in the color that you specify in the conditional formatting. Refer attached workbook, I've used Red color. Once the data is pasted, the duplicates will be highlighted and can be removed manually later.

  11. #11
    Valued Forum Contributor Saarang84's Avatar
    Join Date
    02-19-2009
    Location
    Chennai, India
    MS-Off Ver
    XL 2003 to 2010
    Posts
    812

    Re: Formula for Duplicate prevention

    Quote Originally Posted by SHUN S View Post
    Hi Saarang84,
    Thanks 4 yr effort and time.

    I think it would help me a lot.

    Kindly reveal the formula and process behind the RED highlight.

    Thanks and regards,
    SHUN
    Hi,

    The formula behind the red highlighting is as in my post #4, here data starts from cell A1 :
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    On Home tab strip, go to conditional formatting new rule, choose Use a Formula to determine which cells to Format option, and give this condition in the textbox below (after changing the column ranges accordingly as per your need). Then click Format button, keep Font style as Bold and color as White and in Fill Tab choose Red color and click OK twice. Now the formula is ready.

  12. #12
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Hyderbad
    MS-Off Ver
    Excel 2003
    Posts
    123

    Re: Formula for Duplicate prevention

    Hi SHUN S,

    Try this code with example : Column A (Deletes duplicates in Column A (entire row).

    Please Login or Register  to view this content.

+ 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. Simple Copy/Paste Macro with Duplicate Prevention.
    By MrWines in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-29-2013, 05:14 AM
  2. Excel 2007 : Prevention of Paste in Data Validation
    By aravindsr22 in forum Excel General
    Replies: 3
    Last Post: 10-19-2011, 10:57 AM
  3. Prevention of posting unsuitable threads
    By Stuart Farr in forum Excel General
    Replies: 1
    Last Post: 07-24-2007, 11:41 PM
  4. Duplicate prevention from Listbox selections to worksheet
    By Casey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-12-2006, 01:59 PM
  5. [SOLVED] prevention emergency kay - for experts
    By markgora@hotmail.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-04-2005, 07:06 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