Multi-Workbook Data Sync

Automatically synchronise data between two Excel workbooks with real-time updates when cells change in the master file.

80 views

Perfect For:

  • Master-slave data replication
  • Distributed team data sharing
  • Backup automation
  • Cross-workbook reporting
  • Data consolidation

PRO Template

Sign up for free to unlock the complete VBA code and access all templates

VBA Code (Preview)
Sign up to copy
' Multi-Workbook Data Sync
' Place this code in the master workbook's Worksheet module

Private Sub Worksheet_Change(ByVal Target As Range)
    ' Trigger sync when specific columns are modified
    On Error GoTo ErrorHandler

    ' Define sync columns (A and B)
    Dim syncRangeA As Range
    Dim syncRangeB As Range
    Set syncRangeA = Me.Range("A:A")
    Set syncRangeB = Me.Range("B:B")

    ' Check if changed cell is in sync range
    If Not Intersect(Target, syncRangeA) Is Nothing Or _
       Not Intersect(Target, syncRangeB) Is Nothing Then

        Application.EnableEvents = False

        ' Call sync procedure
        Call SyncToSecondaryWorkbook(Target)

        Application.EnableEvents = True
    End If

    Exit Sub

ErrorHandler:
    Application.EnableEvents = True
    MsgBox "Error during sync: " & Err.Description, vbCritical
End Sub

Sub SyncToSecondaryWorkbook(ByVal changedCell As Range)
    ' Sync changed data to secondary workbook
    On Error GoTo ErrorHandler

    ' Define secondary workbook path
    Dim secondaryPath As String
    secondaryPath = ThisWorkbook.Path & "SecondaryWorkbook.xlsx"

    ' Check if file exists
    If Dir(secondaryPath) = "" Then
        MsgBox "Secondary workbook not found at: " & secondaryPath, vbExclamation

' ... 102 more lines hidden ...
'
' Sign up for free to view the complete code
' Visit: vbacode.io
Access all 45 templates
10 free AI generations/month
No credit card required

Related Topics

sync multiple workbooks real-time data replication automation

Need Custom VBA Solutions?

Our AI-powered VBA generator can create custom code tailored to your specific requirements in seconds.

Generate Custom VBA Code