Results 1 to 9 of 9

Simple Copy/Paste Macro with Duplicate Prevention.

Threaded View

  1. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Simple Copy/Paste Macro with Duplicate Prevention.

    Hi, and welcome to the forum.

    The way I usually trap this situation is to use a MATCH() function. So for example in your case in another cell named say 'Check" add

    Formula: copy to clipboard
    =IF(ISERROR(MATCH(L12,Output!A:A,False)),"OK","Duplicate")


    Then your macro is

    Sub GENERATOR()
    
       IF Range("Check") = "Duplicate" Then
          MsgBox "There is a duplicate on the Output sheet. This record will not be added."
          Exit Sub
       End If
    
       Range("L12").Copy
       Sheets("OUTPUT").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial(xlPasteValues)
    
    End Sub
    Incidentally please remember to use code tags around any code you include as per the forum rules.
    Last edited by Richard Buttrey; 08-28-2013 at 06:20 AM.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

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
    By Katsdog in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-14-2013, 11:49 AM
  2. Replies: 3
    Last Post: 04-04-2013, 04:57 PM
  3. [SOLVED] Simple copy and paste macro- Paste special help needed.
    By hernancrespo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2012, 07:02 AM
  4. [SOLVED] Simple copy and paste macro
    By hernancrespo in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-08-2012, 08:16 AM
  5. Simple Copy/Paste Macro???
    By kwright90 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-02-2007, 01:22 PM

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