Matching data from one workbook to another and copying...

snapgt

New Member
Joined
Sep 18, 2013
Messages
1
I have two Excel files, one is my MasterWorkbook which grabs data from multiple workbooks and compiles it in a single sheet, and another file, B1, which is the data source. To date, the data in B1 has been manually copied into MasterWorkbook. Here is a sample of what MasterWorkbook looks like:

[TABLE="width: 256"]
<tbody>[TR]
[TD="width: 64, align: center"]Dealer #[/TD]
[TD="width: 64, align: center"] Name[/TD]
[TD="width: 64, align: center"] Price[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"] AAA[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"] BBB[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"] CCC[/TD]
[TD="align: center"]3[/TD]
[/TR]
[TR]
[TD="align: center"] 2[/TD]
[TD="align: center"] Abc[/TD]
[TD="align: center"]4[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"] DEF[/TD]
[TD="align: center"]5[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"] GHI[/TD]
[TD="align: center"]6[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"] JKL[/TD]
[TD="align: center"]7[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"] MNO[/TD]
[TD="align: center"]8[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"] PQR[/TD]
[TD="align: center"]9[/TD]
[/TR]
</tbody>[/TABLE]

Here is what B1 looks like:
[TABLE="width: 256"]
<tbody>[TR]
[TD="width: 64, align: center"]Name[/TD]
[TD="width: 64, align: center"]New Price[/TD]
[/TR]
[TR]
[TD="align: center"]AAA[/TD]
[TD="align: center"]100[/TD]
[/TR]
[TR]
[TD="align: center"]BBB[/TD]
[TD="align: center"]110[/TD]
[/TR]
[TR]
[TD="align: center"]CCC[/TD]
[TD="align: center"]120[/TD]
[/TR]
</tbody>[/TABLE]

What I believe should happen is that the code should look at the dealer # first, if it is equal to 1, open B1, if it is equal to 2, open B2, etc. Once the appropriate data workbook is opened, the correct name needs to be found and the associated price should be copied from the data source and into the price column of the MasterWorkbook. A few things to keep in mind, the MasterWorkbook is dynamic in terms of the number of rows and the order of dealers and names. The data sources are random in terms of their order (i.e. tomorrow it might be CCC in row 1, AAA in row 2, BBB in row 3).

So, once the code is run, the final table should look like this (assuming data source B2 has identical prices as what is in the MasterWorkbook):
[TABLE="width: 256"]
<tbody>[TR]
[TD="width: 64, align: center"]Dealer #[/TD]
[TD="width: 64, align: center"]Name[/TD]
[TD="width: 64, align: center"]Price[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]AAA[/TD]
[TD="align: center"]100[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]BBB[/TD]
[TD="align: center"]110[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]CCC[/TD]
[TD="align: center"]120[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]Abc[/TD]
[TD="align: center"]4[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]DEF[/TD]
[TD="align: center"]5[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]GHI[/TD]
[TD="align: center"]6[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]JKL[/TD]
[TD="align: center"]7[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]MNO[/TD]
[TD="align: center"]8[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]PQR[/TD]
[TD="align: center"]9[/TD]
[/TR]
</tbody>[/TABLE]

I have attempted this but keep getting hung up on switching between the two workbooks once they both are opened. I also have issues pasting the information into the MasterWorkbook as I keep getting various object errors. Any suggestions on how to do this would be appreciated!

Thanks!
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top