PDA

View Full Version : Need help with VBA find match



Pasi12
01-22-2014, 02:14 PM
HI ,

I am trying to find/ compare 2 columns "A" and "B" and find the match , then copy the match into a new worksheet. Would appreciate any help?
Here is what I have but only colors the cells if it finds a match I want to copy that match into new wksheet?
Thanks!
Pasi



Sub ColorDuplicates()
'Color duplicate items between columns A and B
For i = 1 To Range("E65536").End(xlUp).Row
If Application.WorksheetFunction.CountIf(Range("A:A"), Range("E" & i)) = 1 Then
With Range("E" & i).Font
.ColorIndex = 5
.Bold = True
With Range("F" & i).Font
.ColorIndex = 5
.Bold = True
End With
End With
End If
Next i
For i = 1 To Range("A65536").End(xlUp).Row
If Application.WorksheetFunction.CountIf(Range("E:E"), Range("A" & i)) = 1 Then
With Range("A" & i).Font
.ColorIndex = 3
.Bold = True
With Range("C" & i).Font
.ColorIndex = 3
.Bold = True
End With
End With
End If
Next i
End Sub

D_Marcel
01-22-2014, 03:23 PM
Pasi12, you mean that, if there's a value in the column A, "Storm", for example, and in the column B there is also the same value "Storm", then copy this single value "Storm" into a new Worksheet?

Pasi12
01-22-2014, 03:39 PM
Yes Marcel.

in column A I have code lets say 68452 and some where in the same worksheet on column "D" I have the same code "68452" with its description. ( The sheet is huge and there are too many data to compare). Now with my code they are colored red and blue, that way I can tell yes there is a match. Now I want to copy the red or bule matched cells to copy to new sheet. Below is an example. Thanks a lot!

Older code Description


68452
F044-IgE Strawberry