Version Control for VBA Projects: Pro Tips
You can (and should) put VBA under Git. The trick is to export text modules.
1) Export modules as text
Use a small helper to export/import .bas, .cls, .frm files so Git can diff them.
' Exports all code modules to a folder Public Sub ExportModules(ByVal folder As String) Dim vbComp As Object For Each vbComp In ThisWorkbook.VBProject.VBComponents vbComp.Export folder & Application.PathSeparator & vbComp.Name & "." & FileExtension(vbComp) Next vbComp End Sub
2) Repository structure
/srcfor exported modules/buildfor packaged add-ins- README with build steps
3) Workflow tips
- Branch for features
- Pull requests / code reviews
- Tag releases
4) Tools
- Rubberduck (inspections)
- VBE add-ins and scripts to automate export/import
5) Backups & recovery
Commit often. Store remote backups. Test restores.
Work faster with the VBA Assistant
Create, explain, and improve your VBA code with examples, comments, and best practices—directly in your workflow.
