Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default sheets that mirror each other

My workbook only has 2 sheets. If the user edits cell "A1"
on Sheet1, I want that data to be copied into "A1" on Sheet2.
My users also work on Sheet2, so if they edit cell "A1" on
Sheet2, I need to copy that same data to the "A1" on Sheet1.

How can I do this?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 833
Default sheets that mirror each other

Hi Robert.

I don't think that you can do that.

You can do the following:-

1. Enter the data in sheet 1 cell A1.

2. On sheet 2 at cell A1 enter the following:-

=Sheet1!A1

3. This way the data in both cells will be identical.

4. I do not think that you can do the, €śvice / versa€ť though.

If my comments have helped please hit Yes.

Thanks!



"Robert Crandal" wrote:

My workbook only has 2 sheets. If the user edits cell "A1"
on Sheet1, I want that data to be copied into "A1" on Sheet2.
My users also work on Sheet2, so if they edit cell "A1" on
Sheet2, I need to copy that same data to the "A1" on Sheet1.

How can I do this?


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default sheets that mirror each other

In sheet1 code module put this:
Private Sub Worksheet_Change(ByVal Target As Range)
Sheet2.Range(Target.Address).Value = Target.Value
End Sub

in Sheet2 code module this:
Private Sub Worksheet_Change(ByVal Target As Range)
Sheet1.Range(Target.Address).Value = Target.Value
End Sub

Mike F
"Robert Crandal" wrote in message
...
My workbook only has 2 sheets. If the user edits cell "A1"
on Sheet1, I want that data to be copied into "A1" on Sheet2.
My users also work on Sheet2, so if they edit cell "A1" on
Sheet2, I need to copy that same data to the "A1" on Sheet1.

How can I do this?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default sheets that mirror each other

Wouldn't this cause an infinite loop or something???
Sheet2 will try to mirror the contents of Sheet 1, but
Sheet 1 will also notice the cell change and try to mirror Sheet2
and vice versa, on and on and on???

What do you think?

"Mike Fogleman" wrote in message
...

In sheet1 code module put this:
Private Sub Worksheet_Change(ByVal Target As Range)
Sheet2.Range(Target.Address).Value = Target.Value
End Sub

in Sheet2 code module this:
Private Sub Worksheet_Change(ByVal Target As Range)
Sheet1.Range(Target.Address).Value = Target.Value
End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default sheets that mirror each other

It worked OK on my test sheets. This assigns a value to a cell and does not
trigger the Change event in the other sheet. Editing the cell does, but only
for that sheet.

Mike F
"Robert Crandal" wrote in message
...
Wouldn't this cause an infinite loop or something???
Sheet2 will try to mirror the contents of Sheet 1, but
Sheet 1 will also notice the cell change and try to mirror Sheet2
and vice versa, on and on and on???

What do you think?

"Mike Fogleman" wrote in message
...

In sheet1 code module put this:
Private Sub Worksheet_Change(ByVal Target As Range)
Sheet2.Range(Target.Address).Value = Target.Value
End Sub

in Sheet2 code module this:
Private Sub Worksheet_Change(ByVal Target As Range)
Sheet1.Range(Target.Address).Value = Target.Value
End Sub






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default sheets that mirror each other

Try putting a MsgBox("Im in Sheet1") statement in the
Worksheet_Change() function for sheet1. It will
give you about 45 message boxes/dialog boxes that
say "I'm in Sheet1". It appears that Excel runs out of
stack space at that point.

so it appears that the Change event is triggered in the
other sheets as well.

"Mike Fogleman" wrote in message
...
It worked OK on my test sheets. This assigns a value to a cell and does
not trigger the Change event in the other sheet. Editing the cell does,
but only for that sheet.

Mike F
"Robert Crandal" wrote in message
...
Wouldn't this cause an infinite loop or something???
Sheet2 will try to mirror the contents of Sheet 1, but
Sheet 1 will also notice the cell change and try to mirror Sheet2
and vice versa, on and on and on???

What do you think?

"Mike Fogleman" wrote in message
...

In sheet1 code module put this:
Private Sub Worksheet_Change(ByVal Target As Range)
Sheet2.Range(Target.Address).Value = Target.Value
End Sub

in Sheet2 code module this:
Private Sub Worksheet_Change(ByVal Target As Range)
Sheet1.Range(Target.Address).Value = Target.Value
End Sub





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default sheets that mirror each other

Let me study this once more. There must be a way, maybe with an IF
statement.

Mike F
"Robert Crandal" wrote in message
...
Try putting a MsgBox("Im in Sheet1") statement in the
Worksheet_Change() function for sheet1. It will
give you about 45 message boxes/dialog boxes that
say "I'm in Sheet1". It appears that Excel runs out of
stack space at that point.

so it appears that the Change event is triggered in the
other sheets as well.

"Mike Fogleman" wrote in message
...
It worked OK on my test sheets. This assigns a value to a cell and does
not trigger the Change event in the other sheet. Editing the cell does,
but only for that sheet.

Mike F
"Robert Crandal" wrote in message
...
Wouldn't this cause an infinite loop or something???
Sheet2 will try to mirror the contents of Sheet 1, but
Sheet 1 will also notice the cell change and try to mirror Sheet2
and vice versa, on and on and on???

What do you think?

"Mike Fogleman" wrote in message
...

In sheet1 code module put this:
Private Sub Worksheet_Change(ByVal Target As Range)
Sheet2.Range(Target.Address).Value = Target.Value
End Sub

in Sheet2 code module this:
Private Sub Worksheet_Change(ByVal Target As Range)
Sheet1.Range(Target.Address).Value = Target.Value
End Sub







  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default sheets that mirror each other

How about the following code in the Worksheet_Change()
for Sheet1:

If Application.ActiveSheet.CodeName = "Sheet1" Then
' copy data to Sheet2
End if

Then, in the code for Worksheet_Change() for Sheet2,
use the following:

If Application.ActiveSheet.CodeName = "Sheet2" Then
' copy data to Sheet1
End if

What do you think about that idea??


"Mike Fogleman" wrote in message
...
Let me study this once more. There must be a way, maybe with an IF
statement.

Mike F
"Robert Crandal" wrote in message
...
Try putting a MsgBox("Im in Sheet1") statement in the
Worksheet_Change() function for sheet1. It will
give you about 45 message boxes/dialog boxes that
say "I'm in Sheet1". It appears that Excel runs out of
stack space at that point.


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default sheets that mirror each other

Yes, that seems to do it:
sheet1 code

Private Sub Worksheet_Change(ByVal Target As Range)
If Application.ActiveSheet.CodeName = "Sheet1" Then
Sheet2.Range(Target.Address).Value = Target.Value
Else
Exit Sub
End If
'MsgBox ("Im in Sheet1")
End Sub

sheet2 code

Private Sub Worksheet_Change(ByVal Target As Range)
If Application.ActiveSheet.CodeName = "Sheet2" Then
Sheet1.Range(Target.Address).Value = Target.Value
Else
Exit Sub
End If
'MsgBox ("Im in Sheet2")
End Sub

Mike F
"Robert Crandal" wrote in message
...
How about the following code in the Worksheet_Change()
for Sheet1:

If Application.ActiveSheet.CodeName = "Sheet1" Then
' copy data to Sheet2
End if

Then, in the code for Worksheet_Change() for Sheet2,
use the following:

If Application.ActiveSheet.CodeName = "Sheet2" Then
' copy data to Sheet1
End if

What do you think about that idea??


"Mike Fogleman" wrote in message
...
Let me study this once more. There must be a way, maybe with an IF
statement.

Mike F
"Robert Crandal" wrote in message
...
Try putting a MsgBox("Im in Sheet1") statement in the
Worksheet_Change() function for sheet1. It will
give you about 45 message boxes/dialog boxes that
say "I'm in Sheet1". It appears that Excel runs out of
stack space at that point.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
synchronizing mutiple sheets to mirror the previous data FEMoore Excel Discussion (Misc queries) 0 October 10th 10 03:49 PM
Mirror View Dattatraya Excel Discussion (Misc queries) 2 May 19th 10 07:45 PM
Mirror Cells Nicolas Cachanosky Excel Programming 3 January 29th 07 05:05 PM
Mirror spreadsheet? Rykar2 Excel Discussion (Misc queries) 4 November 12th 05 03:50 AM
2 mirror files with :1 and :2 - why? DJR Excel Discussion (Misc queries) 3 March 21st 05 06:05 PM


All times are GMT +1. The time now is 08:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"