Append to existing sheet if file exists and create file if it doesn't exist
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello Experts,
I am looking for a way to create a new excel sheet if the file does not exist and append to existing file(also sheet) if the file is already present and write data to them .
For example,
We need to dynamically create a file called "test_exec. xlsx" if the flag is set as "0" and append to existing sheet if flag is set as "1"
Can somebody help me on this?
Thanks in advance :)
Solved! Go to Solution.
- Labels:
- Batch Macro
- Common Use Cases
- Developer
- Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello @jaimonsk ,
I recommend you to use 2 batch macros for that.
The first one would only accept the files flagged as 0. You pass as a parameter all the file names and data which would be written as new files
Do the same then for the second file but for the one flagged as 1, using this time an output but with the append property.
If you need an example for it let me know.
Kind regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello afv2688,
Could you give me a demo as you described above. I was actually planning to integrate this into a standard macro which we built in order prepare an analysis upon each workflows and macros which we are currently running so that we could prepare some analysis of the time consumed by each workflow.So this "test_exec.xlsx" needs to be created if it does not exist and if it is existing, the current row needs to be appended below existing lines.
Again thanks for the help :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @jaimonsk
@afv2688 has a good solution, but you can accomplish the same result in a simple workflow...no macros required.
The Output tool on the top branch is configured to create the file if it doesn't exist. The bottom one appends if the file does exist. The directory browser read the files from the target directory and joins this with the list of filenames from the data. Matches, which correspond to existing files, are routed to bottom output. Non-matches go out the L output where the file is created.
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
This works great.Thank you so much danilang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
This is fabulous concept! Thank you! danilang
