Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare 2 columns using VBA

Status
Not open for further replies.

Gutierrez

Technical User
Dec 10, 2004
44
US
I have 2 worksheets .. and want to compare worksheet1 column "A" and worksheet2 column "A" if worksheet2 Column "A" is not a match then i would like to copy and paste it to worksheet 3 .. along with a few more columns on that row .. how can this be done?

thanks in advance.
 
Have you ever used Access? This sounds like a simple query for Access to handle. You would first have to import your worksheets into Access tables, then you could create a query that will compare values in the two tables, finding the records that don't match up. Then you could take the results of the query and shoot them back out to Excel.
 
Actually .. I would have had this thing finished by now ... but the company I work for doesnt support MS Access ... so all has to be done in Excel ... I agree .. a query and then a data dump to excel would be the answer .. but cant do it.
 
Do you want to compare the ENTIRE column - like an all-or-nothing situation where if the entire columns don't match, then copy the whole thing. OR do you want compare each individual cell in the column?

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
each individual cell in the column ... so what i want is basically an unmatched query to be run ... if a number exsist in worksheet2 column "A" but not in worksheet1 column "A" then i want that entire row to be copied to worksheet3.
 
have a look at this thread: thread707-538073

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
xlbo ... with all the code in that thread .. i am not sure which one to use .. could u define or copy the code to this post?

and so that we are cleare .. here is what i need:

worksheet2 column"A" ="123ABC"

if any cell in worksheet1 Column"A" = "123abc" then i want to ignore it but if not then copy entire row to Worksheet3

Thanks
 
Have a look at Advanced Filter in Excel.

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
Gutierrez - all of the code could work for you - it is different ways of doing the same thing. Try reading the thread and using the help files to find out the differences between them

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
if you have any specific questions about the code used in that thread, I will be happy to answer them but I tend not to answer general questions.

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top