• 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.

How to create a new file on first instance and collate data in same file for next attempts

ThrottleWorks

Excel Ninja
Hi,

I need to collate data from a worksheet.

On every day, if the macro is getting executed for the first time, then macro should create a new file, paste data from input sheet in sheet1 of new file, save it and close it.

From 2nd instance onwards, macro should collate the data in new created file.

For example,

today, 1st instance count = 100
today, 2nd instance count = 100
today, 3rd instance count = 100
today, 4th instance count = 100
today, 5th instance count = 100

so the final count from collated file will be 500
How do I do this. Can anyone please help me in this.
 
Last edited:
Hi,

I would probably store the new file's ".Full Name" in some way (a cell perhaps) and then use
Code:
If Dir("File's full name here") = "" Then
to check if the file already exists. If it does, open the workbook, if it doesn't, create new one.

Also, if the cell where the file's name is to be stored = "", it means it is the first instance and you can skip to "create new file".
 
vletm

I would recommend to have two separate command buttons .

1) Command button 1
This is for your first instances to run which will create a new workbook and will paste data from input sheet in sheet1 of new file, save it and close it.

2) Command button 2
This is for your second, third or so on instances which will collate the data in new created file.

Hope this helps!
 
Hi @PCosta87 , thanks a lot for the help. This exact idea came to my mind yesterday while going home. Have a nice day ahead. :)


Hi @vletm , thanks a lot for the help. Have a nice day ahead. :)

Hi @Monty , thanks a lot for the help. Have a nice day ahead. :)
 
Back
Top