View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Lynda Lynda is offline
external usenet poster
 
Posts: 115
Default Matching 2 columns

Thank you Jacob, it works a treat.

Cheers
Lynda

"Jacob Skaria" wrote:

Hi Lynda

Please ignore the previous post.....For your query please try the below
macro which use ColD as a temporary column and try to find a match in ColA.
Once a match is done for all entries in ColB ColA is replaced with ColD. Does
that suit your requirement?

Sub MatchAndDelete()
Dim lngRow As Long, rngTemp As Range
Set rngTemp = Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)

For lngRow = 1 To Cells(Rows.Count, "B").End(xlUp).Row
If Trim(Range("B" & lngRow)) < "" Then
If WorksheetFunction.CountIf(rngTemp, Range("B" & lngRow)) 0 Then
Range("D" & lngRow) = Range("B" & lngRow).Text
End If
End If
Next
Range("A:A") = Range("D:D").Value
Range("D:D").ClearContents
End Sub



If this post helps click Yes
---------------
Jacob Skaria


"Lynda" wrote:

Sorry folks but I am having a brain dead moment because I know I have done
this before. I have three columns of data, in column A I have a list of
names, in column B I have another list of names that are matched up with the
dates in column C. I want to be able to match up the names in column B with
the names in column A by forcing the names in column B down until they find a
match in column A. Column A has more names than column B and not all names
have a match. The names in column A that dont have a match will be deleted.
A B C
Ashton, Bobbie Brown, Joe 1/2/1967
Brown, Joe Jones, Penny 8/7/1972
Crisp, Jason Smith, John 12/6/1981
Smith, John

Hope this makes sense. Thanks in advance.
Cheers
Lynda