Greetings,
I will get directly to the point.
*What I Have.
1)-I have one folder which contains multiple excel workbooks. All of them are in .xlsx format.
2) Each workbooks has multiple worksheets
3)The important sheet for me is the first one of each workbook, which has a dynamic name i.e. the name of the sheet is not same in any workbook nor there is a pattern to the name. The only similar thing is that the important sheet is always the first sheet.
4)The data of every first worksheet has same no. of columns but different number of rows.
The rows can range from 02 to 60k too.
5)The data of every first worksheet has headings and all the headings are same in each first worksheet of workbook
6)A new workbook gets added to the folder occasionally.
*What I want-
I could actually do with any of the 2 variation of macro. But if possible, the 1st one is preferable.
Variation (1)
1)I want a vba code for macro which opens all work present workbooks in the folder and copies all the data of the first sheet of each workbook with headers.
2)The same macro then opens the master workbook from a different but a specified path.
(Note:- The point I am highlighting is that the master workbook is already created and is saved with the name "MASTER WORKBOOK.xlsx" in a different path before running the macro and macro in this version therefore does not create the master workbook it just opens the master workbook and then pastes the data in it.)
3)The data copied is then pasted in sheet1 of master workbook one below another. The data should be pasted with headers. The data should be pasted only in one single sheet just one below other for each workbook that it is combining.
4)As the data is getting copied and pasted with headers, It will be really helpful if there is any way to highlight those rows which contains the headers, each time they are being pasted in a row. This is just optional. If this is possible then it is big plus but if not then it's still ok.
5) Save and close the master workbook and close all the workbooks from which data was copied.
6) Whenever a new workbook is added to the folder, the macro then should only pick up the new file and run the process of copying the first sheet's data and then paste it below the last row of data in the master workbook's first sheet. This is key element of this version. If possible please suggest a way to execute this.
Variation (2)
1)I want a vba code for macro which opens all work present workbooks in the folder and copies all the data of the first sheet of each workbook with headers.
2)- macro then creates a new excel file.
(Note:- in this variation of the macro, the macro creates the master workbook)
3)The data copied is then pasted in sheet1 of newly created excel file, one below another. The data should be pasted with headers. The data should be pasted only in one single sheet just one below other for each workbook that it is combining.
4)As the data is getting copied and pasted with headers, It will be really helpful if there is any way to highlight those rows which contains the headers each time they are being pasted. This is just optional. If this is possible then it is big plus but if not then it's still ok.
5) Save the workbook as "MASTER WORKBOOK.xlsx" and close it. And also close all the workbooks from which data was copied. It doesn't matter where the file is getting saved It could be a new path or in the same path of the folder.
6) Whenever a new workbook is added to the folder then the macro in this variation will process the code on all the workbooks from the start and create a new master workbook and replace the old one while saving the new master workbook created.
Difference between two variation -
1)
-The first variation copy and pastes the data in an existing workbook.
-The second variation always creates a new file to copy and paste.
2)
-In first variation,the macro will run only on newly added file/s in folder whenever it is added and save the master workbook with newly added data.
-The second variation will always start from the beginning and run the code on all files again whenever a new file is added and create and save new master workbook while replacing old one.
Any variation of macro will work for me just that 1st one is preferable.
I can understand that this is really complex and can be time consuming but kindly help me through this.
I am just getting started in macro. So please let me know if I have to keep any workbooks open while running the macro or not. Like should I keep open the master workbook or the workbooks from which data is going get copied before running the macro or anything else.
Thank you very much in advance.
I will get directly to the point.
*What I Have.
1)-I have one folder which contains multiple excel workbooks. All of them are in .xlsx format.
2) Each workbooks has multiple worksheets
3)The important sheet for me is the first one of each workbook, which has a dynamic name i.e. the name of the sheet is not same in any workbook nor there is a pattern to the name. The only similar thing is that the important sheet is always the first sheet.
4)The data of every first worksheet has same no. of columns but different number of rows.
The rows can range from 02 to 60k too.
5)The data of every first worksheet has headings and all the headings are same in each first worksheet of workbook
6)A new workbook gets added to the folder occasionally.
*What I want-
I could actually do with any of the 2 variation of macro. But if possible, the 1st one is preferable.
Variation (1)
1)I want a vba code for macro which opens all work present workbooks in the folder and copies all the data of the first sheet of each workbook with headers.
2)The same macro then opens the master workbook from a different but a specified path.
(Note:- The point I am highlighting is that the master workbook is already created and is saved with the name "MASTER WORKBOOK.xlsx" in a different path before running the macro and macro in this version therefore does not create the master workbook it just opens the master workbook and then pastes the data in it.)
3)The data copied is then pasted in sheet1 of master workbook one below another. The data should be pasted with headers. The data should be pasted only in one single sheet just one below other for each workbook that it is combining.
4)As the data is getting copied and pasted with headers, It will be really helpful if there is any way to highlight those rows which contains the headers, each time they are being pasted in a row. This is just optional. If this is possible then it is big plus but if not then it's still ok.
5) Save and close the master workbook and close all the workbooks from which data was copied.
6) Whenever a new workbook is added to the folder, the macro then should only pick up the new file and run the process of copying the first sheet's data and then paste it below the last row of data in the master workbook's first sheet. This is key element of this version. If possible please suggest a way to execute this.
Variation (2)
1)I want a vba code for macro which opens all work present workbooks in the folder and copies all the data of the first sheet of each workbook with headers.
2)- macro then creates a new excel file.
(Note:- in this variation of the macro, the macro creates the master workbook)
3)The data copied is then pasted in sheet1 of newly created excel file, one below another. The data should be pasted with headers. The data should be pasted only in one single sheet just one below other for each workbook that it is combining.
4)As the data is getting copied and pasted with headers, It will be really helpful if there is any way to highlight those rows which contains the headers each time they are being pasted. This is just optional. If this is possible then it is big plus but if not then it's still ok.
5) Save the workbook as "MASTER WORKBOOK.xlsx" and close it. And also close all the workbooks from which data was copied. It doesn't matter where the file is getting saved It could be a new path or in the same path of the folder.
6) Whenever a new workbook is added to the folder then the macro in this variation will process the code on all the workbooks from the start and create a new master workbook and replace the old one while saving the new master workbook created.
Difference between two variation -
1)
-The first variation copy and pastes the data in an existing workbook.
-The second variation always creates a new file to copy and paste.
2)
-In first variation,the macro will run only on newly added file/s in folder whenever it is added and save the master workbook with newly added data.
-The second variation will always start from the beginning and run the code on all files again whenever a new file is added and create and save new master workbook while replacing old one.
Any variation of macro will work for me just that 1st one is preferable.
I can understand that this is really complex and can be time consuming but kindly help me through this.
I am just getting started in macro. So please let me know if I have to keep any workbooks open while running the macro or not. Like should I keep open the master workbook or the workbooks from which data is going get copied before running the macro or anything else.
Thank you very much in advance.