I have two cells on different worksheets and I want to be able to link one cell to the other so that changing either cell will change the other as well. Or, alternatively, each cell links to a third cell that changes whenever either of the other two cells is changed.
I have no experience with VBA, but I found a thread here that showed me how to link one cell to another by editing the code of the worksheet; however, I can only do this within the same worksheet and have not figured out how to do it for two worksheets.
Here is the code I currently have, which changes cell A3 whenever A1 or A2 change:
I tried setting cell A2 in sheet1 equal to the value in sheet2, then using this code, but changing the value in sheet2 didn't change the value in A3 in sheet1 even though the value in cell A2 changed.
Again, I have no experience or knowledge of VBA so any help/advice/direction to other helpful posts would be greatly appreciated.
I have no experience with VBA, but I found a thread here that showed me how to link one cell to another by editing the code of the worksheet; however, I can only do this within the same worksheet and have not figured out how to do it for two worksheets.
Here is the code I currently have, which changes cell A3 whenever A1 or A2 change:
Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$1" Or Target.Address = "$A$2" Then
a = Range("a1")
b = Range("a2")
Application.EnableEvents = False
If Target.Address = "$A$1" Then
Range("a3").Value = a
Else
Range("a3").Value = b
End If
End If
Application.EnableEvents = True
End Sub
I tried setting cell A2 in sheet1 equal to the value in sheet2, then using this code, but changing the value in sheet2 didn't change the value in A3 in sheet1 even though the value in cell A2 changed.
Again, I have no experience or knowledge of VBA so any help/advice/direction to other helpful posts would be greatly appreciated.