Is there a macro to conditionally copy data to another worksheet?

bvanstarkenburg

New Member
Joined
Jun 28, 2017
Messages
1
At my work I have two databases with the same products. The first database contains all the products with all possible combinations (in this istance the database consists of motor exhausts, which are available in different colors and materials). The second database only contains the base product. The product ID of the combinations correspondences with the ID of the base products. The database with the base products also contains a lot of information about the products.

Sample data combinations
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;">- Product ID - Reference number
1.12012 E3A02ET7
2.12012 E3A02EN7
3.12013 E3A02ES6
4.12014 E9A03ES
5.12014 E9A03EN

</code>Sample data base
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;">- Product ID - Name - Price - Reference number
1.12012 Gilera Fuoco 363 E3A02ET
2.12013 Gilera Nexus 363 E3A02ES
3.12014 Gilera Runner 363 E9A03EN

</code>Prefered output
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;">- Product ID - Name - Price - Reference number
1.12012 Gilera Fuoco 363 E3A02ET7
2.12012 Gilera Fuoco 363 E3A02EN7
3.12013 Gilera Nexus 363 E3A02ES6
4.12014 Gilera Runner 363 E9A03ES
5.12014 Gilera Runner 363 E9A03EN

</code>Since I want to upload every product to my webshop, I need to format the combinations database in the same way as the base product database, with all the useful information. The way I want to do this, is to use a macro that only copies the combinations product reference number, with the entire base product row, if the combinations product's ID matches the base product's ID. Since a lot of combinations products match the same base product's ID, the macro needs to copy the data multiple times. Also, the combinations database has information about the exhaust's material and color in another colon (I exluded it to make my sample database less messy.). If it's possible, I want to add this information to the product name.
Much obliged,

B. van Starkenburg

(Cross-linked from stack overflow.)
 

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,223,909
Messages
6,175,313
Members
452,634
Latest member
cpostell

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