Compare 2 workbooks and copy data

Steffmeister

Board Regular
Joined
Nov 7, 2005
Messages
195
Hi guys,

I got a question and maybe somebody can help me?
I got some addresses in a sheet. I want to compare these addresses with another workbook (QIP.xls). This workbook exists of a few sheets with addresses and got data till column E.
Now I’d like to have the data from workbook QIP.xls into the worksheet with the addresses I’d like to compare. Does somebody know a macro for this?

Grts. Steffmeister :)
 

Some videos you may like

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

gingerafro

Active Member
Joined
Mar 23, 2005
Messages
448
Do you want to take the data from the sheets in QIP.xls and stack them on top of each other in your first spreadsheet so you can do a vlookup or something

or

Do you want to do some sort of lookup in the sheets and only copy across the data that matches?
 

Steffmeister

Board Regular
Joined
Nov 7, 2005
Messages
195
gingerafro said:
Do you want to take the data from the sheets in QIP.xls and stack them on top of each other in your first spreadsheet so you can do a vlookup or something

or

Do you want to do some sort of lookup in the sheets and only copy across the data that matches?

Hi Gingerafro,

The addresses in the first spreadsheet must be compared with the QIP.xls addresses and the data of QIP.xls must be copied in the first spreadsheet. So the second solution what you said is what I tried to explain :biggrin:.
 

gingerafro

Active Member
Joined
Mar 23, 2005
Messages
448
When you say addresses, is this a postal address extending over several cells or another type of address in just one cell.

Would a vlookup work (ie is the data in one cell exactly the same as QIP.xls)

How many sheets are there?

How much of the data do you want to copy (columns A to E, I expect?)
 

Steffmeister

Board Regular
Joined
Nov 7, 2005
Messages
195

ADVERTISEMENT

gingerafro said:
When you say addresses, is this a postal address extending over several cells or another type of address in just one cell.

Would a vlookup work (ie is the data in one cell exactly the same as QIP.xls)

How many sheets are there?

How much of the data do you want to copy (columns A to E, I expect?)

They are IP-addresses so the data is exact the same.
There are 5 sheets in QIP.
I'd like to copy column A to E pls.
 

gingerafro

Active Member
Joined
Mar 23, 2005
Messages
448
Unless you are doing this regularly, I would personally do it manually with vlookups.

1. Do a vlookup on the first sheet and return column A only. I anticipate that you have a lot of data so wouldn't recommend doing all 5 colums at once.
2. Sort by the column you have just returned (sending all N/As to the bottom.
3. Redo the vlookup for the rest of the columns on the values that you know you have matches for.
4. Go to the next sheet and start again.

If you can write vlookup formulas, this process would take no longer than 20 minutes, and be a lot less complicated than writing a macro!!
 

Steffmeister

Board Regular
Joined
Nov 7, 2005
Messages
195

ADVERTISEMENT

Hi Gingerafro,

Tnx for the advice, but I must do a few 100 addresses every week. So maybe a macro is faster and smoother then?
Hope you can help me?

Tnx
 

gingerafro

Active Member
Joined
Mar 23, 2005
Messages
448
I think that the method I posted will work for you (although I am obviously working blind on this), and if you want to have a macro, I would start by using the macro recorder.

If you've not used the macro recorder before, then the best advice is to sit and think about what you are going to do before you do it. Everytime you perform an action with the recorder turned on, puts something into your macro. Its not dangerous, just makes editing messy.

So, in summary.
Do the job you want to do manually first without the recorder on so you know the method exactly.
Record a macro whilst doing the task manually.
Edit the vba to make it less messy, possibly quicker and (and I think you'll need this for what you are doing) more intuitive.

If you would like help with part 3. post the recorded macro on and i can see what you have done. It'll also help with understanding your method.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,035
Messages
5,569,782
Members
412,292
Latest member
The Bear named Joe
Top