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....

I have two different spreadsheets (Spreadsheet's 1 and 2)
that I want to mirror each other. Here is the code that I am
using to achieve this for each sheet:

'
' Worksheet_change() for "Sheet1"
'
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
For Each t In Target
Sheet2.Range(t.Address(0, 0)).Value = t.Value
Next t
Application.EnableEvents = True
End Sub

'
' Worksheet_change() for "Sheet2"
'
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
For Each t In Target
Sheet1.Range(t.Address(0, 0)).Value = t.Value
Next t
Application.EnableEvents = True
End Sub


Does anybody see any flaws in the code above??? I want both sheets
to miror each other exactly at all times, but I noticed in a few situations
that the data on both sheets does not match exactly and I'm puzzled
as to why??

Would anybody mind running the above code and try to find situations
that might break the mirror?? Otherwise, can anybody see a flaw in
the code?

thank you


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

Okay....I found a scenario which will break my code below.

On Sheet1, type some data into any cell, but do NOT press
the Enter key to finalize the data entry. After you type in
the data, immediately change to Sheet2. Now change back
to Sheet1. Notice that the data on both sheets is different
now??

Does anybody know how I can solve this problem scenario???

Basically, if I change to Sheet2 before I actually trigger a
"change" event in Sheet1, the data will not transfer over to Sheet2.





"Robert Crandal" wrote in message
...
I have two different spreadsheets (Spreadsheet's 1 and 2)
that I want to mirror each other. Here is the code that I am
using to achieve this for each sheet:

'
' Worksheet_change() for "Sheet1"
'
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
For Each t In Target
Sheet2.Range(t.Address(0, 0)).Value = t.Value
Next t
Application.EnableEvents = True
End Sub

'
' Worksheet_change() for "Sheet2"
'
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
For Each t In Target
Sheet1.Range(t.Address(0, 0)).Value = t.Value
Next t
Application.EnableEvents = True
End Sub


Does anybody see any flaws in the code above??? I want both sheets
to miror each other exactly at all times, but I noticed in a few
situations
that the data on both sheets does not match exactly and I'm puzzled
as to why??

Would anybody mind running the above code and try to find situations
that might break the mirror?? Otherwise, can anybody see a flaw in
the code?

thank you



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Sheets that mirror each other....

Robert,
you posted this question before & had some responses including one I posted.
Code I posted as an idea is as follows - it may or may not do what you are
trying to do but may give you some further ideas.

I am out of office now until new year!

'sheet 1
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng1 As Range
Dim rng2 As Range

Application.EnableEvents = False

Sheets(2).Cells.ClearContents

Set rng1 = Sheets(1).UsedRange

Set rng2 = Sheets(2).Range("A1")

rng1.Copy rng2

Application.EnableEvents = True

End Sub

'sheet 2
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng1 As Range
Dim rng2 As Range

Application.EnableEvents = False

Sheets(1).Cells.ClearContents

Set rng1 = Sheets(2).UsedRange

Set rng2 = Sheets(1).Range("A1")

rng1.Copy rng2

Application.EnableEvents = True

End Sub



--
jb


"Robert Crandal" wrote:

Okay....I found a scenario which will break my code below.

On Sheet1, type some data into any cell, but do NOT press
the Enter key to finalize the data entry. After you type in
the data, immediately change to Sheet2. Now change back
to Sheet1. Notice that the data on both sheets is different
now??

Does anybody know how I can solve this problem scenario???

Basically, if I change to Sheet2 before I actually trigger a
"change" event in Sheet1, the data will not transfer over to Sheet2.





"Robert Crandal" wrote in message
...
I have two different spreadsheets (Spreadsheet's 1 and 2)
that I want to mirror each other. Here is the code that I am
using to achieve this for each sheet:

'
' Worksheet_change() for "Sheet1"
'
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
For Each t In Target
Sheet2.Range(t.Address(0, 0)).Value = t.Value
Next t
Application.EnableEvents = True
End Sub

'
' Worksheet_change() for "Sheet2"
'
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
For Each t In Target
Sheet1.Range(t.Address(0, 0)).Value = t.Value
Next t
Application.EnableEvents = True
End Sub


Does anybody see any flaws in the code above??? I want both sheets
to miror each other exactly at all times, but I noticed in a few
situations
that the data on both sheets does not match exactly and I'm puzzled
as to why??

Would anybody mind running the above code and try to find situations
that might break the mirror?? Otherwise, can anybody see a flaw in
the code?

thank you



.

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
Problem with sheets that mirror each other Robert Crandal Excel Programming 10 December 12th 09 03:46 PM
sheets that mirror each other Robert Crandal Excel Programming 8 December 5th 09 01:54 PM
Mirror value to another cell. Eric Excel Programming 2 July 31st 08 03:59 AM
Mirror spreadsheet? Rykar2 Excel Discussion (Misc queries) 4 November 12th 05 03:50 AM


All times are GMT +1. The time now is 12:45 PM.

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

About Us

"It's about Microsoft Excel"