Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
synchronizing mutiple sheets to mirror the previous data | Excel Discussion (Misc queries) | |||
Mirror View | Excel Discussion (Misc queries) | |||
Mirror Cells | Excel Programming | |||
Mirror spreadsheet? | Excel Discussion (Misc queries) | |||
2 mirror files with :1 and :2 - why? | Excel Discussion (Misc queries) |