Unique records of matching pairs

P

pmarques

Hello!
I need to filter unique records acording to two columms (10xy and
error).
I want the unique ocurrences of this pairs of columms independently of
the other columms.

I have tried with advanced filter but if the columm ID is diferent and
the pair (10xy and error) is the same, it will give me another record
that i don't want.

I have an example attached. In yellow the result that i want.

Thank´s :)


+-------------------------------------------------------------------+
|Filename: tests.zip |
|Download: http://www.excelforum.com/attachment.php?postid=3946 |
+-------------------------------------------------------------------+
 
G

Guest

The easiest way is to concatenate the two fields together in a new column and
then filter that for unique items.
 
G

Guest

Hi,
These few lines of code worked OK on your test file. As per Jim's
reply, I concatenated columns B & E in column F. Then just execute module.

HTH

Sub GetUnique()

lastrow = Cells(Rows.Count, "A").End(xlUp).Row

Set ConRng = Range("F6:F" & lastrow) ' Concatenation of "10XY" and "Error"

j = 6 ' Output row
r = 6 ' First input row

Do While r < lastrow
Range(Cells(r, "A"), Cells(r, "E")).Copy Cells(j, "G") 'Output first
record
j = j + 1 ' Increment count of output row
n = Application.CountIf(ConRng, Cells(r, "B") & Cells(r, "E")) ' Count
of records with this key
r = r + n ' set to next concatenated key
Loop

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top