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:

Dealer # Name Price
1 AAA1
1 BBB2
1 CCC3
2 Abc4
2 DEF5
2 GHI6
2 JKL7
2 MNO8
2 PQR9

<tbody>
</tbody>

Here is what B1 looks like:
NameNew Price
AAA100
BBB110
CCC120

<tbody>
</tbody>

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):
Dealer #NamePrice
1AAA100
1BBB110
1CCC120
2Abc4
2DEF5
2GHI6
2JKL7
2MNO8
2PQR9

<tbody>
</tbody>

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

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,215,256
Messages
6,123,914
Members
449,132
Latest member
Rosie14

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