Computing.Net > Forums > Office Software > compare two columns in excel

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

compare two columns in excel

Reply to Message Icon

Name: grdipajek
Date: February 10, 2009 at 01:32:15 Pacific
OS: Windows XP
Subcategory: Microsoft Office
Comment:

Hi,
I have got two columns in excel table. Both columns contain names of companies in Croatia. My task is to compare those columns to see if there are duplicate entries. If I find company"x" in column A and column B that entry should be moved from column A and pasted in column C so that at the end I have column A and column B that have no identical entries and column C that contain all duplicate entries found in A and B.
Help would be much appreciated.



Sponsored Link
Ads by Google

Response Number 1
Name: DerbyDad03
Date: February 10, 2009 at 10:31:14 Pacific
Reply:

Assuming your lists start in A1 and B1, and you want your results to start in C1, this should work:

Sub CompCol()
CellCount = Range("A" & Rows.Count).End(xlUp).Row
 For NxtChk = CellCount To 1 Step -1
  With Columns("B")
   Set c = .Find(Cells(NxtChk, 1), lookat:=xlWhole)
    If Not c Is Nothing Then
     NxtCell = NxtCell + 1
      Cells(NxtChk, 1).Copy Destination:=Cells(NxtCell, 3)
      Cells(NxtChk, 1).Delete shift:=xlUp
    End If
  End With
 Next
End Sub


0

Response Number 2
Name: grdipajek
Date: February 11, 2009 at 06:48:42 Pacific
Reply:

This works perfectly!
Thank You very much.


0

Response Number 3
Name: DerbyDad03
Date: February 12, 2009 at 11:12:56 Pacific
Reply:

Glad I could help.

Thanks for the feedback.


0

Response Number 4
Name: Thewilliamsgrp08
Date: February 26, 2009 at 09:32:18 Pacific
Reply:

I am trying to accomplish the same task, but the code won't work for me. I am running excel 2007, and i have entered the code as a macro and tried to run it, but nothing happened. Can you help?


0

Response Number 5
Name: NancyMB
Date: March 25, 2009 at 09:14:39 Pacific
Reply:

Hi.
Where is the code from Response 1 supposed to be inputted in Excel?


0

Related Posts

See More



Response Number 6
Name: DerbyDad03
Date: March 26, 2009 at 06:09:28 Pacific
Reply:

Open the VBA editor, Insert a Module and paste the code in.

After that it should run against the currently active sheet.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: compare two columns in excel

compare two columns in excel 2007 www.computing.net/answers/office/compare-two-columns-in-excel-2007/8119.html

Comparing two columns in excel www.computing.net/answers/office/comparing-two-columns-in-excel/8993.html

Excel Formula - Compare two columns www.computing.net/answers/office/excel-formula-compare-two-columns/7308.html