Track revision history of Excel macros and compare changes to VBA code

Apart fromkeeping track of changes to Excel workbooks, XLTools add-in also allows VBA version control to track changes to Excel VBA macros. This unique feature is essential for advanced users and Excel VBA developers. It helps compare changes in code, save VBA modules to Git repository or roll back to a previously committed version of macro.

XLTools Version Control for VBA projects keeps your Excel macros safe:

  • Commit versions of a VBA project and track changes
  • Compare code versions line by line and highlight changes
  • Store versions of a macro in a Git repository on your own PC
  • Keep change log and track who changed what and when
  • Recover any previous version of a macro

How to enable Version Control for VBA macros in Excel

  1. Enable Developer macro settings:

    Developer tab Macro Security Check "Trust access to the VBA project object model".
    Or:File Options Trust Center Trust Center Settings Macro Settings Check "Trust access…"
  2. Enable Version Control for the Excel workbook:

    Open the workbook Click theEnablebutton on XLTools ribbon.
    Or:open XLToolsSettings Version Control tab Enable.
  3. Immediately a new folder "WorkbookName_Revisions" will automatically appear at the same destination folder as your workbook. This is theGit repositorythat stores all committed versions.
    Important:do NOT delete, rename or move this folder. Otherwise all versions history will be lost.

How to commit a version of VBA module to Change Log

  1. When you have made changes to the script and want to commit the version, first, save the project.
  2. ClickCommit Changeson XLTools tab A dialogue box will open.
  3. Add a descriptive comment to tell the versions apart OK.
Note:the version is committed only via theCommit Changesbutton. If you simply save the VBA project, the version is not committed to Change Log.

How to preview and diff changes to VBA code before commit

  1. Make changes Click theCommit Changesbutton.
  2. Double click on the modified module to diff and preview changes.
  3. The current and the newer versions of VBA script display next to each other. Changes in code are highlighted line by line.
  4. Review the result Click OK to commit this new version, or Cancel to go back to editing.

How to open Change Log and compare versions of a macro

  1. Click theChange Logbutton A list with all versions displays comments, author and exact time of commit.
  2. Expand/ collapse the list to find the versions of VBA modules want to compare.
  3. HoldCtrland select two modules Click theShow changesbutton.
  4. The older and the newer versions display side by side, changes in code are highlighted.
  1. Click theChange Logbutton Double click on the VBA module you want to restore from the history.
  2. Copy the code from the window Open the macro for editing Paste the code to the VBA module.

How to use Version Control to track changes in Excel workbooks

Whether or not your Excel workbook contains a macro, you can enableversioning of workbooksand track changes made to worksheets.

Any questions or suggestions?
Massimodoes also compare and save versions of class modules?
August 18, 2020 at 07:51
Sebastianis it possible to jump from changed line to changed line when in the "Show Changes" window?
March 26, 2019 at 17:34
Maria BalobanovaHi Sebastian, no, there is no quick jump yet. That's an excellent idea, thank you. We'll keep it in mind for future releases.
March 26, 2019 at 18:41
ZacharyAny VBA Sub I could call to trigger "Commit Changes". Thanks!!
October 1, 2018 at 13:50
alex immanuelany vidoes avalibel for usage of the addin from scracth? this will help us to make decision in purchasing your addin
September 21, 2018 at 07:08
Maria BalobanovaHi Alex, sorry, no videos yet, but have that planned. If necessary, we can organize a demo.
September 21, 2018 at 13:45
Guido CinatoStill no roll back improvements in version 5.0, isn't it?
July 27, 2017 at 17:18
Maria BalobanovaHi Guido, sorry, not yet. I know it's been over a year since we first discussed it. In version 5.0 we focused on new features mainly. As to Version Control, we have gathered more feedback and suggestions to act upon. It does take a lot of development effort, and we think Version Control upgrade should deserve a separate release. I do appreciate you following up on the subject! Please bear with us =)
July 27, 2017 at 21:09
Rajasekaran RajendranHi Team, I would like to know is there any possibilities to restore a file using VBA codes?.
May 26, 2017 at 12:17
Maria BalobanovaHi Rajasekaran, sorry, XLTools does not have a tool to restore a file. You can only restore a previous version of a workbook, if you have activated Version Control and committed versions after making changes to the file.
May 26, 2017 at 16:03
Guido CinatoHi Maria, it seems to me that you still don't have implemented new roll back procedures. Does versioning work also with excel files with old .xls format?
December 16, 2016 at 19:23
Maria BalobanovaHello Guido, Not yet, indeed. It is in our development schedule, though. And yes, Version Control also works for files in .xls format.
December 19, 2016 at 13:50
Guido Cinatovery interesting, but I find the roll back procedure should have better and easier method
April 5, 2016 at 16:35
Maria BalobanovaThanks, Guido. Improving roll-back will be the next step!
April 5, 2016 at 18:30
How can we help?