cells, which write to each other

C

Christian Galbavy

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
 
J

Jim Cone

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
 
B

Bob Phillips

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top