VBA & Macro Problems

How to Create Two-Way Linked Excel Cells with VBA

Elise WilliamsElise Williams Oct 23, 2026 869 views

Question details

The user wants to synchronize two spreadsheet cells so that manually editing either cell automatically updates the other.

How to Create Two-Way Linked Excel Cells with VBA
Product
Excel
Device & OS
not provided
Scenario
Attempting to create dynamic, bidirectional cells where either cell functions as both an input and an output.
Observed behavior
Standard formulas are overwritten when edited manually, and attempts to link them cause circular references. A VBA solution or alternative design is required to achieve two-way synchronization.
Before you start

Ensure your workbook is saved as a Macro-Enabled Workbook (.xlsm) and that you have enabled macros in your spreadsheet security settings before running VBA code.

Solution 1Recommended

Use a Worksheet_Change VBA Event

Implement a VBA script that detects manual edits to specific cells and updates the linked cell dynamically without triggering an infinite loop.

VBA is required for this approach because ordinary formulas get overwritten when you manually type data into a cell. By utilizing the Worksheet_Change event, Excel can listen for user inputs and mirror the changes to the corresponding cell.

It is critical to temporarily disable application events during the update. If you do not, the macro's change to the second cell will trigger the Worksheet_Change event again, causing an endless recursion loop that can freeze the application.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Access the Worksheet Module

In the Project Explorer pane on the left, find your workbook and double-click the specific worksheet name (e.g., Sheet1) where the linked cells are located.

3
Insert the Event Code

Select 'Worksheet' from the left dropdown and 'Change' from the right dropdown at the top of the code window. Write an If statement checking the Target.Address to identify which cell was edited.

4
Disable Events and Update the Target Cell

Before modifying the linked cell in the code, add the line 'Application.EnableEvents = False'. Next, write the logic to update the other cell, then immediately restore event tracking with 'Application.EnableEvents = True'.

Handling Errors: Include an error handler (e.g., On Error GoTo) in your VBA script to ensure 'Application.EnableEvents = True' executes even if the script fails, otherwise macros will stop triggering entirely.

Use WPS Spreadsheet for Seamless VBA Integration

WPS Office provides a fully equipped, robust macro environment that allows you to easily implement two-way linked cells using VBA. You can write, edit, and execute Worksheet_Change events just like you would in Microsoft Excel.

  1. 1. Open your Document in WPS: Launch WPS Spreadsheet and open your existing workbook.
  2. 2. Access the Developer Tools: Navigate to the Developer tab on the top ribbon and click on 'VBA Editor'.
  3. 3. Add Your Macro Code: Double-click the desired sheet module and insert your Worksheet_Change event code.
  4. 4. Save the Workbook: Go to File > Save As, and choose 'Macro-Enabled Workbook (*.xlsm)' to preserve your two-way cell links.
High compatibility with Microsoft Excel Macro-Enabled Workbooks (.xlsm)Familiar VBA editor interface for easy navigation and scriptingSeamlessly execute complex macros and event listenersFree and lightweight Office alternative
microsoft office alternative - wps office

Frequently Asked Questions

Why can't I use standard formulas to link two cells to each other?

Standard formulas work in a one-way direction. If you create a formula in Cell A to reflect Cell B, manually typing a new value into Cell A will overwrite and delete the formula, permanently breaking the link.

Why does my VBA code freeze or crash Excel when updating linked cells?

This happens due to an infinite loop, or recursion. When your VBA code changes a cell, it triggers the Worksheet_Change event again, which runs the code again, repeating endlessly. You must use 'Application.EnableEvents = False' to pause event triggers while the macro updates the target cell.

Will this VBA method work on the web versions of spreadsheet apps?

No. VBA macros are not supported in web-based spreadsheet applications like Excel for Web or WPS Web. You must use the desktop applications to write and run VBA scripts for two-way synchronization.