• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Split Parent-Child data into different worksheets & save each one of them as a csv file

inddon

Member
Hello There,

Thank you for taking the time to look into my post and helping me out.

I have a workbook with 3 worksheets as below:
1. "Customer Header" --> Columns Customer ID, Customer Name & Amount
(This contains unique row for each Customer ID and their details)
2. "Customer Lines" --> Columns Customer ID, Customer Name, Line Number & Line Amount
(For each of the Customer Header -- Customer ID it can have multiple rows)
3. "Summary" --> Columns Customer ID, Date Created, CSV File Header, CSV File Lines & Number of Rows in each file
(This worksheet reflects the summary fof the operation)

I am looking for VBA module code to perform the following:

1. Split Data: Loop through each row in worksheet "Customer Header"
-Create a worksheet with worksheet name = Customer ID value suffixed with text "_Header"
-In worksheet "Customer Lines", find it's related Customer ID rows and copy these rows.
-Create a worksheet with worksheet name = Customer ID value suffixed with text "_Lines" and paste these copied rows here.
2. CSV File: Loop through each newly created worksheets (i.e. "......_Header" & "....._Lines").
-Create a csv file with the same name as worksheet name.
-In a new row, reflect the following in the worksheet "Summary", for each Customer ID:
-CSV File names
-Customer ID
-Number of rows in the worksheets "..._Header" & "...._Lines"
-and reflect these in the worksheet "Summary"
-Delete the respective worksheet (i.e. "......_Header" & "....._Lines"), for which the csv file was created
3. Clear worksheets "Customer Header" & "Customer Lines"

I wonder if it is possible to create csv files after filtering the rows in the worksheet "Customer Lines" (i.e. without copy & paste in new worksheet and then create csv).

I have attached a sample workbook for your reference.

Look forward to hearing from you.

Thank you & regards,
Don
 

Attachments

  • Sample Workbook CSV Generation.xlsm
    18.3 KB · Views: 1
Hi Don,

Have you got answer to our query? We are having a same requirement and I am looking for a VBA code to achieve this.

Thanks in advance!
 
Hi Gauri_40,​
you should better create your own thread​
with an attachment reflecting exactly the source data like accordingly the expected result as well​
and with your best accurate crystal clear complete explanation as any Excel forum expects for …​
 
Back
Top