Macro to built final file from 3 different files

Status
Not open for further replies.

Cris_93

New Member
Joined
Nov 1, 2019
Messages
22
Office Version
  1. 2016
Platform
  1. Windows
Hello Excel masters :)

I need your help in order to develop a final file (CustomerForecast) from 3 different files with some restrictions.

The final file should have the below format. The columns "FactType" and "Unit" should have always the same values.


Depot/StoreFormatProductFactTypeUnitDateValue
DublinRTP088Customer ForecastCases02/11/201923
BelfastRTB222Customer ForecastCases12/11/201932
HatfieldRTP088Customer ForecastCases07/11/201930
DordonRTL008Customer ForecastCases05/11/201930

<tbody>
</tbody>


The other data for the others 4 columns come from the below 3 different files. I will put in red the required columns from each file:

"ROI.csv"

Supplier numberCategory areaStar lineTpnbDescriptionTpndCase sizeOccDepot numberDepot nameForecast dateOrder dateDelivery dateForecast cases
5997500MFPN52440995PORK MINCE 500G3141187385.05E+12735BALLYMUN FRESH PBL03/10/201904/10/201905/10/201940
5997500MFPN52445008IRISH LAMB MINCE 15% FAT 533G3721698045.06E+12735BALLYMUN FRESH PBL03/10/201904/10/201907/10/201910
5997500MFPN52483552T. ROUND STEAK BEEF MINCE 10% FAT 554G34945576125.06E+12735BALLYMUN FRESH PBL03/10/201916/10/201917/10/2019102
5997500MFPN63755738T. FIN* IRISH CANADIAN MAPLE RASHERS 240G3260775085.06E+12735BALLYMUN FRESH PBL03/10/201921/10/201922/10/201948

<tbody>
</tbody>


The Depot name "BALLYMUN FRESH PBL" should be picked as "Dublin" to the final file;

"NI.xls"

Supplier numberOccTpndDescriptionDepot numberDepot nameCase sizeForecast dateOrder dateDelivery date
Forecast cases
62422002.0955E+1128798712T.FIN 1 BEEF RIBEYE STEAK835NI BELFAST FRESH PBL1203/10/201919/10/2019
21/10/2019
2
62422002.0955E+1128798712T.FIN 1 BEEF RIBEYE STEAK835NI BELFAST FRESH PBL1203/10/201910/10/2019
11/10/2019
8
62422002.0955E+1128798712T.FIN 1 BEEF RIBEYE STEAK835
NI BELFAST FRESH PBL1203/10/201905/10/201907/10/2019
21
62422002.0955E+1128798712T.FIN 1 BEEF RIBEYE STEAK835NI BELFAST FRESH PBL1203/10/201909/10/201910/10/2019
9
...

<tbody>
</tbody>

The Depot name "NI BELFAST FRESH PBL" should be picked as "Belfast" to the final file;

"Ocado.xls"

Forecast Delivery Date
Delivery PlaceOrder GroupSKU
Supplier Line NumberProduct DescriptionCase Barcode
Forecast Order Qty (Cases)
06 October 2019 05:00:00
DordonDo: HFS7776001177760011Ocado Lean Beef Steak Mince 5% Fat (500 GR)1505500419560
06 October 2019 05:00:00
DordonDo: HFS296274011296274011Eden Beef Steak Mince 15% Fat (500 GR)0539181024238
06 October 2019 08:30:00
HatfieldHa: HFS435984011435984011Eden Lean Beef Steak Mince 5% Fat (400 GR)0539181110251
07 October 2019 08:00:00
Erith CFCEr: HFS7258101172581011Ocado 4 Quarter Pounder Beef Burgers (454 GR)150550023822
07 October 2019 08:00:00
Erith CFCEr: HFS402166011402166011Eden Aberdeen Angus Beef Roasting Joint (1.5 KG)953918110686

<tbody>
</tbody>


As you for sure noticed the "Product" on the final file has a different format/id than in the three files "Tpnd" and "SKU". That's because for each product from our costumers we use a specific internal code (Retail code). The match between our suppliers code and our RT codes is made in a different file called "Week Forecast" and has the bellow aspect.


TPNDCodeDescription
22918725RPP001T GAMMON STKS WT CARMELISED ONION MPQAS
RPP001CPTESCO GAMMON STEAK WITH CARMELISED CP
RPP001WPWIP TESCO GAMMON STEAK WITH CARMELISED
22918656RPP002TESCO BACON CHOPS WT MSTRD BUTTER MPQAS
RPP002CPTESCO BACON CHOPS WITH MUSTARD BUTTR CP
RPP002WPWIP TESCO BACON CHOPS WITH MUSTARD BUTTR
RPP003MARKET VALUE PALE BACK BACON JOINT
RPP003WPWIP MARKET VALUE PALE BACK BACON JOINT
RPP004MARKET VALUE PALE HAM FILLET
RPP004WPWIP MARKET VALUE PALE HAM FILLET
23966061RPP005TESCO THICK CUT SMKD RASHERS 250G MPQAS
RPP005WPWIP SMOKED THICKCUT BACK BACON RASHERS
23966147RPP006TESCO THICKCUT MAPLE RASHERS 250G MPQAS
RPP006WPWIP THICKCUT MAPLE BACK BACON RASHERS

<tbody>
</tbody>


Some of the codes are inactive. The only active code is the one in front of the Tpnd code. The macro should match the code from the supplier and pick the correspondent Retail Code to the final file.

Thanks a lot guys!

Kind regards,
Cristian
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Duplicate https://www.mrexcel.com/forum/excel...a-3-files-create-final-file-restrictions.html

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).

Note that sometimes posts from new users require Moderator approval before you can see them on the public forums. When this happens, you should see a message to that effect when you try to post it.
Please be patient and do not attempt to post the question again.

 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,983
Messages
6,122,582
Members
449,089
Latest member
Motoracer88

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