Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to create a VBA script that would save a copy of the document every 5-10 minutes with a new name. The script would keep like 10-15 copies in the same folder, incrementing a number each time. If it reaches the max number of saves, it should delete the oldest one.

For example:

document.xlsx - Working copy.  
document_b1.xlsx - First backup, done after 5 minutes.  
document_b2.xlsx - Second backup, after 10 minutes.  

And so on, and so on.
When this number at the end reaches 15, the script should rename the rest.

document_b15 - gets deleted.  
document_b14 -> document_b15  
document_b13 -> document_b14  
document_b1 - new copy. 

What kind of function could do the steps required?
A short list the VBA would need:

  • Incrementing a valuable
  • Renaming files
  • Deleting file
  • Saving the current document as a new file

I'm aware that the Q belongs to Stackoverflow. Regarding the programming part.
But I want to use an existing solution, rather than learning VBA from scratch.

Is there a VBA that would do this for me?

share|improve this question
up vote 3 down vote accepted

I wrote a quick auto-backup add-in for Excel.
Can you please test it and report your bugs? I will improve it if necessary.


  1. Download the Add-In
  2. save it at C:\Documents and Settings\USERNAME\Application Data\Microsoft\AddIns\
  3. Open Excel and navigate to
    (Excel 2003) Menubar → Tools → Add-ins
    (Excel 2007) Start-button → Excel Options → Add-Ins → drop down: Excel add-ins → Go
    (Excel 2010) File tab → Options → Add-Ins → drop down: Excel add-ins → Go
  4. check myautobackup

What it does

  • saves a backup file for each open workbook
  • a new folder called autobackup is created at the same place as the workbook
  • up to 3 backups are saved there
  • save date is appended to original backup file name
  • time interval is 10 seconds
  • newly created workbooks which aren't saved yet by the user aren't saved by autobackup
    (They have no valid path yet)
  • source code (34 lines) can be viewed on pastebin.
    Additionally an open-event will start the auto backup

Note: These low time delay and count settings are only for early testing. You can easily. change them later

enter image description here

share|improve this answer
Sounds great! You should really make a github page for the script. I mean... a lot of people would love to have a great addon. – Shiki Jan 20 '13 at 11:45

You must log in to answer this question.

protected by Community Jul 3 '14 at 22:00

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged .