Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Mirror two cells between worksheets and edit either way

0

Hi, I am new. Apologies for any errors in posting.

Can anybody suggest how to mirror two cells on different worksheets?

I want to be able to edit one cell and the other is updated automatically - and vice versa.

Many thanks.

Answer
Discuss

Answers

0
Selected Answer

Hello ExPanRider and welcome to the forum.

You haven't provided a sample file so I can only offer general guidance.

Let's assume the cell you edit is C3 on Sheet1 and the mirror cell is F5 on Sheet2.

In F5 on Sheet2 enter this: =('Sheet1'!C3) .

Obviously you will need to edit the sheet name and/or cell reference to match your situation.

See attached file for example.

Updated June 1 @ 11:10

I have attached Mirror Cell V2 (modified version of the original file) which uses Worksheet_Change event code. I figured out how to prevent the endless loop I  decribed in discussion below. The V2 file achieves what you are looking to do.

Sheet1 code:

Private Sub Worksheet_Change(ByVal Target As Range)

' macro written by WillieD24 for teachexcel.com

If Range("C3") = Sheet2.Range("F5") Then Exit Sub

If Target = Range("C3") Then
' both of the following lines will do the same thing
    Sheet2.Range("F5") = Sheet1.Range("C3")
    'Sheet1.Range("C3").Copy Sheet2.Range("F5")
End If

End Sub

Sheet2 code:

Private Sub Worksheet_Change(ByVal Target As Range)

' macro written by WillieD24 for teachexcel.com

If Range("F5") = Sheet1.Range("C3") Then Exit Sub

If Target = Range("F5") Then
' both of the following lines will do the same thing
    'Sheet1.Range("C3") = Sheet2.Range("F5")
    Sheet2.Range("F5").Copy Sheet1.Range("C3")
End If

End Sub

If this is what you were looking for please mark my answer as selected.

Cheers   :-)

Discuss

Discussion

Hi, Thanks for the response.
I am hoping for two-way mirroring.  Edit either cell and the other one will change.
I have chganged the wording or the original question.
I hope that is clearer.
ExPanRider (rep: 2) Jun 1, '23 at 10:06 am
Hello again,

The only way (I know of) to achieve what you want would be with the Worksheet_Change event but that creates an endless loop.
When Sheet1 C3 changes then Sheet2 F5 changes to match, which triggers the other change event that when Sheet2 F5 changes the Sheet1 C3 changes to match. That then triggers the Sheet1 change event which then triggers the Sheet2 change event etc etc etc . . . . . 

If I figure out a different method I will post it.
WillieD24 (rep: 557) Jun 1, '23 at 10:51 am
Good news! I figured out how to prevent the endless loop.
I have attached the revised file (Mirror Cell V2) to my original answer above.

Cheers   :-)
WillieD24 (rep: 557) Jun 1, '23 at 11:14 am
Thank you. That is great.  Many thanks for your help.
ExPanRider (rep: 2) Jun 3, '23 at 6:28 am
I'm glad I could help and Thank You for selecting my answer.
WillieD24 (rep: 557) Jun 3, '23 at 8:44 am
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login