I have a compare between 2 worksheets I have been using but it is very ridged. I am looking to make it less so. What the workbook is doing now is inserting a column A to sheets "Update" and "Base" that is equal to "A1"&"B1" and copied to the end of the column. Once the compare is complete the columns are deleted. What I trying to do is remove the need to inserted the columns. I would like to using the Application.Union function, however it works for Application.Union(sh2.Range("A2:A" & LR), sh2.Range("B2:B" & LR)), but, change the second part of the to say "Range("C2:C" & LR)" I get a "TYPE MISMATCH". Can anyone help?
Code:
Sub Des_mod_compare_2222222()
Dim sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet, LR As Long, rng As Range, C As Range
Dim i As Long, C1 As Long, C2 As Long, C3 As Long, C4 As Long
Set sh1 = Sheets("Base") 'Edit sheet name
Set sh2 = Sheets("Update") 'Edit Sheet name
Set sh3 = Sheets("Des Changes") 'Edit sheet name
LR = sh2.Cells(Rows.Count, 1).End(xlUp).Row
Set rng = Application.Union(sh2.Range("A2:A" & LR), sh2.Range("B2:B" & LR))
For Each C In rng
If Application.CountIf(Application.Union(sh1.Range("A:A"), sh1.Range("B:B")), C.Value) = 0 Then
sh2.Range("A" & C.Row).Resize(1, 1).Copy sh3.Cells(Rows.Count, 1).End(xlUp)(2)
End If
Next
End Sub