Results 1 to 8 of 8

Thread: Excel VBA Search For Find Duplicate Values In Two Lists

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    Here is a slightly shorter, non-looping macro that will do what you want as well (just change the assignments in the Const statements I highlighted in red to match your actual setup)...
    Code:
    Sub ListDupes()
      Dim LastRow As Long, List2Address As String
      Const WS As String = "Sheet2"
      Const List1Col As String = "A"
      Const List2Col As String = "D"
      Const OutputCol As String = "E"
      Const StartRow As Long = 2
      LastRow = Worksheets(WS).Cells(Rows.Count, List2Col).End(xlUp).Row
      List2Address = List2Col & StartRow & ":" & List2Col & LastRow
      Application.ScreenUpdating = False
      With Worksheets(WS).Cells(StartRow, OutputCol).Resize(LastRow - StartRow + 1)
        .Cells = Evaluate("IF(COUNTIF('" & WS & "'!" & List1Col & ":" & List1Col & ",'" & WS & _
                          "'!" & List2Address & "),'" & WS & "'!" & List2Address & ","""")")
        On Error Resume Next
        .SpecialCells(xlBlanks).Delete xlShiftUp
        On Error GoTo 0
      End With
      Application.ScreenUpdating = True
    End Sub
    Last edited by Rick Rothstein; 04-22-2013 at 10:07 AM.

Similar Threads

  1. Replies: 6
    Last Post: 05-16-2013, 09:56 AM
  2. Unmerge Cells and Fill with Duplicate Values
    By princ_wns in forum Excel Help
    Replies: 3
    Last Post: 10-09-2012, 07:36 AM
  3. Replies: 2
    Last Post: 11-17-2011, 07:49 PM
  4. Find duplicate values
    By excel_learner in forum Excel Help
    Replies: 4
    Last Post: 10-24-2011, 12:10 PM
  5. Unique Large Values From Duplicate List
    By S M C in forum Excel and VBA Tips and Tricks
    Replies: 0
    Last Post: 10-04-2011, 02:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •