ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   cells, which write to each other (https://www.excelbanter.com/excel-programming/323765-cells-write-each-other.html)

Christian Galbavy[_2_]

cells, which write to each other
 
Hy!

I use the Worksheet_Change-function for two cells to write to each other.
So, I have sheet_1 with cell B1 and sheet_2 with cell B1. Everytime, when
the user changes the content of one of them, the other cell changes it's
content too. That was easy. But now, the user should be able to insert
columns in sheet_1, so it could happen that cell B1 moves to cell C1. So the
function worksheet_change will not work correctly anymore. Is it possible to
handle this problem or is there no solution?

Thanks for your answers!

Regards
Christian Galbavy




Jim Cone

cells, which write to each other
 
Christian,

Name the cells...
'---------------------
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Me.Range("FirstCell").Address Then
Sheet2.Range("SecondCell").Value = Target.Value
End If
End Sub
'---------------------

Regards,
Jim Cone
San Francisco, USA


"Christian Galbavy" wrote in message
...
Hy!
I use the Worksheet_Change-function for two cells to write to each other.
So, I have sheet_1 with cell B1 and sheet_2 with cell B1. Everytime, when
the user changes the content of one of them, the other cell changes it's
content too. That was easy. But now, the user should be able to insert
columns in sheet_1, so it could happen that cell B1 moves to cell C1. So the
function worksheet_change will not work correctly anymore. Is it possible to
handle this problem or is there no solution?
Thanks for your answers!


Regards
Christian Galbavy



Bob Phillips[_6_]

cells, which write to each other
 
Christian,

Here is an idea.

Define two named ranges, say Cell1 and Cell2 with RefersTo values of =$B$1
and =$C$1.

In the worksheet event code, test

If Target = Range("Cell1") Then

etc

--

HTH

RP
(remove nothere from the email address if mailing direct)


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

I use the Worksheet_Change-function for two cells to write to each other.
So, I have sheet_1 with cell B1 and sheet_2 with cell B1. Everytime, when
the user changes the content of one of them, the other cell changes it's
content too. That was easy. But now, the user should be able to insert
columns in sheet_1, so it could happen that cell B1 moves to cell C1. So

the
function worksheet_change will not work correctly anymore. Is it possible

to
handle this problem or is there no solution?

Thanks for your answers!

Regards
Christian Galbavy







All times are GMT +1. The time now is 01:17 AM.

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