ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   link cells (https://www.excelbanter.com/excel-programming/322716-link-cells.html)

Christian Galbavy

link cells
 
Hy!

I want to link to cells with each other. So, if I change one of the cells,
the other one should change too. I have only found a way, where you can only
change one cell, and this will change the other one. But I want to find a
possibility to do this in both directions.
Anybody, who has an idea?

Christian



Tom Ogilvy

link cells
 
you can do this with the change event. Right click on the sheet tab of the
sheet where you want this behavior and select view code. Put in a macro
like this one:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrHandler
If Target.Count 1 Then Exit Sub
If Target.Address = "$A$1" Or Target.Address = "$B$10" Then
Application.EnableEvents = False
If Target.Address = "$A$1" Then
Range("B10").Value = Target.Value ^ 2
Else
Range("A1").Value = Target.Value ^ 0.5
End If
End If
ErrHandler:
Application.EnableEvents = True
End Sub

As an example, this one synchronizes Cells A1 and B10 so B10 is always the
square of A1, regardless of where the entry is made - B10 or A1.

--
Regards,
Tom Ogilvy

"Christian Galbavy" wrote in message
...
Hy!

I want to link to cells with each other. So, if I change one of the cells,
the other one should change too. I have only found a way, where you can

only
change one cell, and this will change the other one. But I want to find a
possibility to do this in both directions.
Anybody, who has an idea?

Christian






All times are GMT +1. The time now is 10:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com