VBA to detect first 3 columns & copy paste the 4th and 5th column

patrickteo91

Board Regular
Joined
Sep 12, 2012
Messages
88
Hi,

I am trying to automate my spreadsheet. Currently I have a template which i need to manually filter another workbook manually in order to get my required data. (Workbook A - template, Workbook B - Database).

Can anyone build a VBA script for me so that it will prompt me to select a file. Then it will compare the first 3 columns of Workbook B and copy the 4th and 5th column value into Workbook A ? Basically the template in Workbook A is exactly the same as workbook B.

It must be able to read signs like -, &, / , etc. and paste into the Date and Volumn column.

Thank you.


Workbook A
CountryDeptContactDateVolume
M&M Shipping - SingaporeFinanceJohn
M&M Shipping - SingaporeFinanceJohn
M&M Shipping - SingaporeFinanceJohn
M&M Shipping - SingaporeFinanceJohn
M&M Shipping - SingaporeFinanceJohn

<TBODY>
</TBODY>

ABC Container - MalaysiaFinanceFaizal
ABC Container - MalaysiaFinanceFaizal
ABC Container - MalaysiaFinanceFaizal
ABC Container - MalaysiaFinanceFaizal
ABC Container - MalaysiaFinanceFaizal

<TBODY>
</TBODY>


Workbook B
CountryDeptContactDateVolume
M&M Shipping - SingaporeFinanceJohn4/5/2013200
M&M Shipping - SingaporeFinanceJohn4/12/2013100
M&M Shipping - SingaporeFinanceJohn4/19/2013500
M&M Shipping - SingaporeFinanceJohn4/26/2013400
M&M Shipping - SingaporeFinanceJohn5/3/2013300
ABC Container - MalaysiaFinanceFaizal4/5/201310
ABC Container - MalaysiaFinanceFaizal4/12/201320
ABC Container - MalaysiaFinanceFaizal4/19/201330
ABC Container - MalaysiaFinanceFaizal4/26/201350
ABC Container - MalaysiaFinanceFaizal5/3/201310

<TBODY>
</TBODY>



<TBODY>
</TBODY><COLGROUP><COL></COLGROUP>
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,213,494
Messages
6,113,972
Members
448,537
Latest member
Et_Cetera

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