Hi folks
I'm a newbie to the forum, new to VBA but not to Excel.
I've written a macro to change details in workbook containing 3 worksheets. Included in this macro is a very simple 'save as' procedure Sub SaveAs() which saves the file with a different name based on a defined string with date (sFileName) - it might look over complicated, but I know what it does and where and it ensures file naming conventions are not compromised when the file is saved. This works without any glitches providing you only run it once each day.
However, if you run it a second time it will produce a message box saying the file exists and would I like to overwite the file. This is correct, but often I need to run it more than once each day and would like the macro to see if the file has already been created and then save as with another name based on the same string but with an additional name part e.g. adding "-01" or "-02".
I've tried using the Sub Exists(), but it does not work correctly, i.e it does not seem to see the file name it's looking for as "sFileName" using Dir. I've intentionally left the parameters out so that it will only look in the default folder where the original source file and the saved as files are.
I'm sure it's something verrrrry simple - but I'm struggling - so can you please help to explain where Sub Exists() is going wrong.
Kind regards and look forward to hearing from you.
Please Login or Register to view this content.
Please Login or Register to view this content.
Bookmarks