Receive new articles directly in your inbox!! Register your email address
Often we manage datasets in which customer information is reported on more than one row. This can be because we have different orders from the same customer
In this post we explore a powerful technique allowing to create individual file per each customer
We will go through the code that allows to loop through a customer database, creating distinct files for each customer—regardless of repetitions in the original list.
The files will be conveniently saved in the same location of the original list. Once all the files are saved the can be used for different purposes such as being emailed to the individual customers as explained in the post How to send emails with attachments to multiple recipients
Starting point is an excel workbook with a first sheet called "Customers" in which the customer information is reported.
The "Customers" sheets looks like this
Customer Donald Duck is reported twice The code will create 5 different files called with the customer name
In each only the information of the customer will be reported The file named DonaldDuck will contain 2 records as customer Donald Duck is reported twice in the original file
The code will go through the following key steps:
An array will be created containing the full customer list
The code wil loop through the array to identify all records containing name and surname of the same customer
A second array will be created where only the information of a specific customer will be copied
The second array will be saved to a new workbook called with the customer name
The complete code is reported below