Compare two columns and remove mismatches

This is just a simple example so I can understand the method - Column A has more data than Column B. I need to figure out how in Column C I can have an "x" appear whenever there is a Column A match to Column B. Basically I need to remove everything from Column A that is not represented in Column B without doing it manually.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Here's a macro that does the deletion as well. It assumes there are no headings.

Sub RemoveUnmatched()
Dim lngLastRow As Long
Dim lngRow As Long
Dim Found As Range

Application.ScreenUpdating = False

lngLastRow = Range("A65536").End(xlUp).Row


For lngRow = lngLastRow To 1 Step -1
    Set Found = Selection.Find(What:=Cells(lngRow, 1).Value, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
        xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False)
    If Found Is Nothing Then
        Cells(lngRow, 1).Delete Shift:=xlUp
    End If

Application.ScreenUpdating = True

End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Martin LissOlder than dirtCommented:
If you don't want to delete automatically, change line 17 to

Cells(lngRow, 3).Value = "X"
Saqib Husain, SyedEngineerCommented:
Enter this formula in C2 and copy it down

Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Martin LissOlder than dirtCommented:
Did any of the above help you?
K_DeutschAuthor Commented:
Like a charm...thanks.
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2013
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.