Shared content between 2 cells on 1 sheet and on 2 sheets

Report
-
Posts
2818
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 18, 2021
-
Hello,
I have cell 'A1' and cell 'B1'
How cand I do a formula so I can tipe something in A1 and B1 is the same content, but I would like it bouth ways, when I type somwthing in B1, the same content to be in A1.
So i need them to be same content, no matter were I type....

Thanks guys!!!


System Configuration: Android / SamsungBrowser 14.2

3 replies

Posts
2818
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 18, 2021
486
Hi Pupic4fun,

Right-click your sheets tab and select 'View code' and paste the code below in the big white field that pops up:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("A1"), Target) Is Nothing Then
    Application.EnableEvents = False
    Range("B1").Value = Target.Value
End If

If Not Intersect(Range("B1"), Target) Is Nothing Then
    Application.EnableEvents = False
    Range("A1").Value = Target.Value
End If
Application.EnableEvents = True
End Sub


Best regards,
Trowa
thanks,
It's working perfect for 1 sheet
what can you do if you have A1 on sheet1 and B1 on sheet2?

thank you in advance
Posts
2818
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 18, 2021
486
Hi Pupic4fun,

Then you will need to add a code to each of the 2 sheets.
Code for sheet1:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("A1"), Target) Is Nothing Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub
Application.EnableEvents = False
Sheets("Sheet2").Range("B1").Value = Target.Value
Application.EnableEvents = True
End Sub


Code for sheet2:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("B1"), Target) Is Nothing Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub
Application.EnableEvents = False
Sheets("Sheet1").Range("A1").Value = Target.Value
Application.EnableEvents = True
End Sub


Make sure your sheet names match those on code line 5 in both codes.

Best regards,
Trowa