I guess I should post the Macro:
Sub CopyDupes()
'Written by Ozgrid Business Applications
'www.ozgrid.com
Dim rList1 As Range
Dim rList2 As Range
Dim rCell As Range
Application.ScreenUpdating = False
Set rList1 = Range("A2", Range("A65536").End(xlUp))
Set rList2 = Range("C2", Range("C65536").End(xlUp))
For Each rCell In rList1
With WorksheetFunction
If .CountIf(rList2, rCell) <> 0 And _
.CountIf(Sheets("Copy").Columns(1), rCell) = 0 Then
rCell.Range("A1:B1").Copy _
Destination:=Sheets("Copy").Range("A65536").End(xlUp).Offset(1, 0)
rList2.Find _
(What:=rCell, after:=rList2.Cells(1, 1)).Range("A1:B1").Copy _
Destination:=Sheets("Copy").Range("C65536").End(xlUp).Offset(1, 0)
End If
End With
Next rCell
Set rList1 = Nothing
Set rList2 = Nothing
Application.ScreenUpdating = True
End Sub
Dave,
Just change the ranges refering to c to e and the range "A1:B1" to "A1:D1" and that should do it.
steve w
Sub CopyDupes()
'Written by Ozgrid Business Applications
'www.ozgrid.com
Dim rList1 As Range
Dim rList2 As Range
Dim rCell As Range
Application.ScreenUpdating = False
Set rList1 = Range("A2", Range("A65536").End(xlUp))
Set rList2 = Range("E2", Range("E65536").End(xlUp))
For Each rCell In rList1
With WorksheetFunction
If .CountIf(rList2, rCell) <> 0 And _
.CountIf(Sheets("Copy").Columns(1), rCell) = 0 Then
rCell.Range("A1:D1").Copy _
Destination:=Sheets("Copy").Range("A65536").End(xlUp).Offset(1, 0)
rList2.Find _
(What:=rCell, after:=rList2.Cells(1, 1)).Range("A1:D1").Copy _
Destination:=Sheets("Copy").Range("E65536").End(xlUp).Offset(1, 0)
End If
End With
Next rCell
Set rList1 = Nothing
Set rList2 = Nothing
Application.ScreenUpdating = True
End Sub
Is there a way of using the TRIM command so as to only remove spaces from the rightmost of a cell, but to retain any doublespaces within a code? I am attempting to use the function to tidy up codes which typically look like this :-
AUA416---4SPIM--1-----
, where '-' signifies a space. The spaces after the final 1 are unwanted, but I need to keep the others. The TRIM command renders the above code as
AUA416-4SPIM-1
which isn't much help to me unfortunately!
Any suggestions would be greatly appreciated......
Steve W,
It Works! Thanks Much!
I have one more question, is there a way to easily find the items that dont match up so I can include them with the end results?
Thanks again.