Link cells without formula? Or through VBA

MikeJRobbins

New Member
Joined
Aug 10, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I'm trying to figure out a way to link two cells without having one be the "master" and the other be the "slave"
1691679790227.png

So the idea is if I type something in A1 it copies over into A2 automatically AND if I type something in A2 it copies over to A1 automatically.
Basically I can type in either cell and it automatically copies.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Welcome to the MrExcel forum!

You need VBA for that. Assuming both cells are on the same sheet, try this:
Open a copy of your workbook, to the sheet with the cells on it. Right click on the sheet tab on the bottom and select "View Code". Paste the following code into the window that opens:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
    Set c1 = Range("A1")
    Set c2 = Range("A2")

    If Target.Address = c1.Address Then
        Application.EnableEvents = False
        c2.Value = c1.Value
        Application.EnableEvents = True
    End If
    
    If Target.Address = c2.Address Then
        Application.EnableEvents = False
        c1.Value = c2.Value
        Application.EnableEvents = True
    End If
    
End Sub

Change the 2 cell references at the top to the cells you want. Close the VBA window and try it out. If the 2 cells are on different sheets, you'll need a macro for each sheet.
 
Upvote 0
I realize this problem is a lot bigger than expected. I essentially was looking for a quick way to link many cells in multiple sheets. I realize now that if I implemented this code as written now, it will take me several months to get it working correctly.

Thanks for your help though. I'm sure this is useful for someone who only needs to map a handful of cells in the same spreadsheet.
 
Upvote 0
Are you talking about multiple cells on different sheets in the same workbook? It might be possible using the ThisWorkbook SheetChange event. Do your cells have any kind of pattern, like A1 on Sheet1 maps to A1 on Sheet2? Do you want something like a "broadcast" where B2 on the Master sheet might propagate to B2 on all the other sheets? Or multiple cells linked together (C3 on any sheet updates C3 on all the other sheets)? If you can explicitly define what you want, we might be able to come up with something.
 
Upvote 0

Forum statistics

Threads
1,215,488
Messages
6,125,092
Members
449,206
Latest member
ralemanygarcia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top