What I’m telling you WILL result in separate files.
generate filename with today’s date
check if file exists
if file doesn’t exist, create it with header row (you could actually do this by having a template Excel file with just the header row, and copying the file)
append data to it
This process will result in a new file every day, that has the header row.
If you want separate files written within a day, then just do a counter variable. Inside a Do While (with “while” of file exists), increment the counter. When you finally get to a filename that doesn’t exist, the Do While will exit, you’ll have your counter value to append to the filename.
Once this completes, counter will have the next number to append to the filename. If counter is still 0 that means you don’t have to append anything to the filename.
Why do you need another approach? Looping works, it’s clean, simple and efficient. Easy to understand for anyone who needs to work with your code in the future.
fetch all the filename from the folder and put for each activity
in for each, extract the counter from your filename
get the maximum value
increment the maximum value+1
then save the file
after getting the file, using right( filename, 1 or 2)
collect the values in loop and check maximum. while coming out of loop, use max+1… only for loop is the activity here