Version Control for VBA macros

Track changes and manage history of VBA projects

Apart from keeping track of history of MS Excel sheets, XLTools Version Control also allows tracking changes in VBA macros. This unique feature is essential for VBA developers to compare changes in code, export VBA modules to git-repository or roll back to a previously committed version of macro.

XLTools Version Control keeps Excel macro data safe:

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

Learn how to use Version Control for VBA macros below, or skip to Version Control for Excel sheets.

XLTools Version Control for VBA macros functionality overview


Add XLTools Version Control to Excel

Works with: Microsoft Excel 2016, 2013, 2010, 2007, Office 365.

Download XLTools Add-in


Learn your way around:


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 workbook:

Open the workbook > Click the ‘Enable’ button on the XLTools ribbon.
Or, open XLTools Settings > Version Control tab > Enable.

Enable XLTools Version Control for VBA

3. Immediately a new folder ‘WorkbookName_Revisions’ will automatically appear at the same destination as your workbook.

Important: do not delete the folder. This is the git-repository that holds all committed versions.

Version Control for VBA macros creates a git repository


How to commit changes to a VBA macro

  1. When you have made changes to the code and want to commit the version, first, save the project.
  2. Click ‘Commit Changes’ on the 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 the ‘Commit Changes’ button. If you simply save the VBA project, the version is not committed to history.

XLTools Version Control Commit Changes to VBA macro


How to preview changes to the VBA script before commit

  1. Click ‘Commit Changes’ > Double click for diff and preview.
  2. The current and the newer versions of the script display side by side. Changes in code are highlighted.
  3. Click OK to commit this new version, or Cancel to go back to editing.

XLTools Version Control VBA script Preview and Commit


How to view the history and compare versions of the macro

  1. Click the ‘Show History’ button > A list with all versions displays comments, author and exact time of commit.
  2. To compare two versions expand the list > Hold ‘Ctrl’ and select any two modules.
  3. Click ‘Show Changes’ > The older and the newer versions display side by side, changes in code are highlighted.

XLTools Select VBA Versions to compare

XLTools Compare VBA Versions side by side


How to restore and roll back to a previous version of a macro

  1. Click the ‘Show History’ button > 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 sheets

Version Control follows the the same logic when tracking changes to Excel sheets. Find details and screenshots here.

 

Any questions or suggestions? Contact us or leave your comment below.

 

2 Responses to Version Control for VBA macros

  1. Guido Cinato says:

    very interesting, but I find the roll back procedure should have better and easier method

Leave a Reply

Your email address will not be published. Required fields are marked *