• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Unmatched coparing two Columns Tab1 with two Columns Tab2

marreco

Member
Hi.

Can you help me this question?

Code:
Option Explicit
Sub GetUnmatched()
'Created by: tigeravatar
'http://www.excelforum.com/excel-programming-vba-macros/774778-excel-vba-find-unmatched.html
'http://www.excelforum.com/excel-programming-vba-macros/1026172-excel-vba-find-unmatched-id-number-and-copy-the-whole-row.html

    Dim ResultSheet As String:          ResultSheet = "Result"  'Here I adapted only between two tabs
    Dim FirstSheet As String:          FirstSheet = "Result"
    Dim SecondSheet As String:          SecondSheet = "Orig"
    Dim FirstSheetDataCol As String:    FirstSheetDataCol = "E"  'How use column E and J here?
    Dim SecondSheetDataCol As String:  SecondSheetDataCol = "E" 'How use column E and J here?
   
    Dim rngData1 As Range:  Set rngData1 = Sheets(FirstSheet).Range(FirstSheetDataCol & "2:" & Sheets(FirstSheet).Cells(Rows.Count, FirstSheetDataCol).End(xlUp).Address)
    Dim rngData2 As Range:  Set rngData2 = Sheets(SecondSheet).Range(SecondSheetDataCol & "2:" & Sheets(SecondSheet).Cells(Rows.Count, SecondSheetDataCol).End(xlUp).Address)
   
    Dim aCell As Range
    For Each aCell In rngData2
        If rngData1.Find(aCell.Value) Is Nothing Then
            Sheets(ResultSheet).Range("A" & Rows.Count).End(xlUp).Offset(1, 0).EntireRow.Value = aCell.EntireRow.Value
        End If
    Next aCell
   
End Sub
Cross-Post
http://www.excelforum.com/excel-pro...g-two-columns-tab1-with-two-columns-tab2.html

Thank you!
 

Attachments

  • UnMached.xlsx
    17.7 KB · Views: 2
Back
Top