Add Error Handling to Save Macro

  • Hi all! I am having some issues adding a new requirement to my existing VBA code. This code works fine as is (although it is a bit slow to run), please forgive me as I am still learning. My new requirement is to add error handling that will advise the user if the file name already exists AND offer the user the option to overwrite the file (or not). I am having issues adding this on my own, as all the examples I have seen have te path and file name hard coded into the VBA code. But my file is a template that auto-generates a filename based on 3 cell variables.


  • Excel will automatically display a message if a file already exists and asks if you want to replace when trying to save it. The "Application.DisplayAlerts = False" statement prevents the warning from popping up. If you remove that line of code, it should take care of your problem. Try this revised macro:

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • You are very welcome. :)

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!