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
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.
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
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.
Summary: Thanks mike, I tried that and nothing happened, that i think was for numbers. What i am looking for is like the post "compare two columns in excel" he was compairing names of companies, and i am just...
Summary: I have a problem, I need to compare data for two columns and a unique value is required. The Problem which I am getting is that I have to compare the data date wise in different months and time wise s...
Summary: Sure. An example would be: A B 1 65434 237.87 2 65467 456.98 3 65597 1008.89 So the above spreadsheet is emailed to me and the sheet will have about 800 rows and I then have to run a sql q...