Create multiple excel workbook in loop
Posted on 2013-11-05
I have access VBA code to collect necessary data to another sheet of the same workbook.
before save and close the sheet, I need to create excel workbooks using the names in the collected sheet.
for example, test.xlxs has two sheets all_data and filtered_data. The sheet filtered_data has cell contain some string like alpha, bravo, charlee, delta.
I want to create excel workbooks named alpha.xlxs, bravo.xlxs, charlee.xlxs and delta.xlxs ,
it will create all strings of that cell in loop then save and close the test.xlxs.
copy some related data to the created excel workbook with a sheet name(use the workbook name)
Set wb_Source_01 = xl.Workbooks.Open("C:\test.xlsx")
Set ws_Source_01 = wb_Source_01.Sheets("all_data")
Set ws_Source_02 = wb_Source_01.Sheets("filtered_data")
first copied necessary data from all_data sheet to filtered_data sheet like below.
ws_Source_02.Cells(LineCounter, 1) = ws_Source_01.Cells(LineCounter, 1)
ws_Source_02.Cells(LineCounter, 2) = ws_Source_01.Cells(LineCounter, 2)
Once all necessary data copied to sheet filtered_data before save and close the workbook, wants to create excel workbook name it one of the cell value of the filtered_data sheet above. then save some related data from the filtered data to that newly created sheet then save it continue until all data of that cell if there 10 then wants to create 10 excel workbooks with the name of the cell in the filtered_data sheet.
Once done finally save and close the work book test.xlxs.
Please advice vba code to do that.