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…"
    XLTools Version Control Macro Settings
  2. Enable Version Control for the Excel workbook:

    Open the workbook Click theEnablebutton on XLTools ribbon.
    Or:open XLToolsSettings Version Control tab Enable.
    Enable XLTools Version Control for VBA modules
  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.
    Version Control for VBA macros creates a git repository

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.
XLTools Version Control Commit Changes to VBA macro

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.
XLTools VBA Version Control: preview, diff and commit changes to code

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.
XLTools Select VBA module versions to compare
XLTools Compare VBA modules side by side
  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.
XLTools Recover and Roll Back To a Previous Version of a the VBA macro

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?
close window
How can we help?