+ Reply to Thread
Results 1 to 8 of 8

Duplicate Values Over Three+ Columns Using VBA

  1. #1
    Forum Contributor
    Join Date
    05-27-2020
    Location
    Bradford
    MS-Off Ver
    office 2016
    Posts
    202

    Duplicate Values Over Three+ Columns Using VBA

    Good Morning Everyone, Happy Christmas and All.

    Please does anybody know who to adapt this code in order for it to look over duplicate information over three or columns rather than just the one. So if the information was in column A, B & C, and I would say want the answer "duplicate" to appear in column D?


    Please Login or Register  to view this content.
    Last edited by KatieA; 12-23-2021 at 05:16 AM.

  2. #2
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2402-17328.20068
    Posts
    1,359

    Re: Duplicate Values Over Three+ Columns Using VBA

    Hi Katie,

    Will the duplicates always be on the same row between columns, for example are you checking row columns A, B & C for them all to match?

    Or

    Are you looking to see if a value in say cell A2 appears anywhere in column A, B & C to denote duplicate?

  3. #3
    Forum Contributor
    Join Date
    05-27-2020
    Location
    Bradford
    MS-Off Ver
    office 2016
    Posts
    202

    Re: Duplicate Values Over Three+ Columns Using VBA

    Good Morning Cheese Sandwich,

    I am looking for the data to match in all at least 5 columns A,B,C,D,E and then declare as duplicate, I have set up a basic example to show you. I would like to show duplicates for the same vehicle, on the same date, customer, postcode and country. I am not sure how to get the code to do this though.
    Attached Files Attached Files

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Duplicate Values Over Three+ Columns Using VBA

    PHP Code: 
    Option Explicit
    Sub test
    ()
    Dim Lr&
    Dim cell As Range
    Lr 
    Cells(Rows.Count"A").End(xlUp).Row
    For Each cell In Range("A1:A" Lr)
        If 
    Application.WorksheetFunction.CountIf(Range("A1:C" Lr), cell) > 1 Then
        cell
    .Offset(, 3).Value "Duplicate"
        
    End If
    Next
    End Sub 
    Quang PT

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Duplicate Values Over Three+ Columns Using VBA

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code (first post in thread).

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  6. #6
    Forum Contributor
    Join Date
    05-27-2020
    Location
    Bradford
    MS-Off Ver
    office 2016
    Posts
    202

    Re: Duplicate Values Over Three+ Columns Using VBA

    Glenn sorry I didnt do this right, I have adjusted it.
    Last edited by KatieA; 12-23-2021 at 05:17 AM.

  7. #7
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Duplicate Values Over Three+ Columns Using VBA

    Try again
    PHP Code: 
    Option Explicit
    Sub test
    ()
    Dim Lr&
    Dim cell As Range
    Dim dic 
    As Object
    Set dic 
    CreateObject("Scripting.dictionary")
    Lr Cells(Rows.Count"A").End(xlUp).Row
    For Each cell In Range("A1:A" Lr)
        If 
    Not dic.exists(cell.Value cell.Offset(01).Value cell.Offset(02).Value cell.Offset(03).Value cell.Offset(04).ValueThen
            dic
    .Add cell.Value cell.Offset(01).Value cell.Offset(02).Value cell.Offset(03).Value cell.Offset(04).Value1
        
    Else
            
    cell.Offset(, 5).Value "Duplicated"
        
    End If
    Next
    End Sub 

  8. #8
    Forum Contributor
    Join Date
    05-27-2020
    Location
    Bradford
    MS-Off Ver
    office 2016
    Posts
    202

    Re: Duplicate Values Over Three+ Columns Using VBA

    Bebo021999, thank you ever so much for showing me how to do this. I have been racking my brain with just normal excel formula. This is exactly what I was looking for, and what I wanted to achieve. This will help me so much now. I am over the moon.

+ 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. [SOLVED] Removing duplicate rows based on single column duplicate values
    By Miasav90 in forum Excel General
    Replies: 7
    Last Post: 09-23-2021, 08:40 AM
  2. Highlight or display duplicate rows not duplicate values
    By olga6542 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-20-2019, 03:24 PM
  3. Replies: 1
    Last Post: 10-12-2018, 12:19 PM
  4. [SOLVED] How to sum duplicate values then remove the duplicate rows?
    By terry3218 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-12-2015, 02:38 AM
  5. Macros to delete entire duplicate row for duplicate values
    By cutelebel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2014, 12:09 PM
  6. Replies: 1
    Last Post: 03-03-2014, 11:06 AM
  7. VBA helps needed to Sum duplicate values and delete duplicate rows
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-03-2013, 11:40 PM

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