VBA & Macro Problems

How to Synchronize Two Excel Workbooks in Both Directions with VBA

WPS Content ManagerWPS Content Manager Oct 9, 2026 874 views

Question details

The user needs a reliable method to synchronize data between two independent desktop Excel workbooks in both directions, including handling updates for cells, ranges, and tables while resolving data conflicts.

How to Synchronize Two Excel Workbooks in Both Directions with VBA
Product
Excel
Device & OS
not provided
Scenario
Managing and updating data across multiple independent desktop workbooks where changes can occur in any file and must be mirrored seamlessly to the other.
Observed behavior
Excel lacks a built-in feature for reliable bi-directional synchronization between independent workbooks, requiring users to rely on custom VBA solutions or one-way updates like Power Query.
Before you start

Before running any VBA macros that modify data across multiple files, ensure you create backup copies of both target workbooks to prevent accidental data loss during synchronization testing.

Solution 1Recommended

Create a Custom VBA Solution for Two-Way Synchronization

Since Excel lacks native two-way sync, writing a custom VBA script is the most reliable way to manage bi-directional updates and resolve data conflicts.

A robust VBA synchronization solution requires tracking changes in both workbooks using unique record identifiers (IDs) and timestamps. You must establish logical rules within the code to handle conflicts when the same record is modified in both files simultaneously.

1
Open the VBA Editor

Open your primary workbook, press ALT + F11 to launch the VBA Editor, and click Insert > Module to create a new script area.

2
Define Workbook Variables

Declare variables to reference both the source and destination workbooks, as well as the specific worksheets and data ranges you want to synchronize.

3
Write the Comparison Logic

Create a loop that iterates through the data rows. For each row, compare the unique key and check the 'Last Modified' timestamp to identify which workbook holds the most recent data.

4
Implement Conflict Handling

Add logic to overwrite older records with newer ones. If timestamps match but data differs, program the script to prompt the user with a MsgBox to manually choose which version to keep.

5
Save and Execute

Save both files as Excel Macro-Enabled Workbooks (.xlsm). Assign the macro to a button on your worksheet and click it to execute the bi-directional sync.

Create a Custom VBA Solution for Two-Way Synchronization
Advanced VBA Knowledge Required: This method requires a strong understanding of VBA scripting, arrays, and event handlers (such as Worksheet_Change) to accurately track modification timestamps.
Free Microsoft Office alternative

Try WPS Office for Advanced Spreadsheet Management

While native bi-directional synchronization requires complex custom VBA scripts in Microsoft Excel, WPS Office provides a lightweight, highly compatible alternative with powerful data processing capabilities. It supports VBA macros seamlessly, allowing you to run your synchronization scripts while enjoying a more cost-effective Office suite.

  1. 1. Download WPS Office: Visit the official WPS website to download and install the free WPS Office suite on your device.
  2. 2. Open Your Workbooks: Launch WPS Spreadsheet and open your existing .xlsm files directly without any format conversion.
  3. 3. Run Your Macros: Enable macros in the WPS settings to execute your VBA synchronization scripts exactly as you would in Excel.
Fully compatible with Microsoft Excel formats (.xlsx, .xlsm, .csv) ensuring no data lossFull support for VBA macros to run your custom workbook synchronization scriptsFree, lightweight, and fast-loading alternative to traditional heavy Office suitesFamiliar user interface that requires zero learning curve for seamless migration
microsoft office alternative - wps office

Frequently Asked Questions

Can I link two Excel workbooks so they update each other automatically?

No, Excel does not natively support true bi-directional linking. Creating simple formula links in both directions will result in a circular reference error. You must use one-way links, Power Query, or write custom VBA scripts for two-way updates.

What is the best way to handle conflicts in a VBA synchronization script?

The most robust method is to add a 'Last Modified' timestamp column to your data tables. Your VBA script can then compare the timestamps for the same record ID in both workbooks and programmatically keep the most recently updated version.

Why shouldn't I use the Consolidate tool for true two-way synchronization?

The Consolidate tool is designed specifically to summarize or aggregate numerical data (like sums or averages) from multiple sources into a single master sheet. It creates a one-way link and cannot push raw data changes back to the original workbooks.