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

Solved/Closed
Pupic4fun - Updated on Aug 30, 2021 at 11:37 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Aug 30, 2021 at 11:32 AM
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
Related:

3 responses

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Aug 17, 2021 at 11:50 AM
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
0
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
0
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Aug 30, 2021 at 11:32 AM
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
0