munim wrote...
I know I can change the structure of the program... I find it more
flexible if I can update in the both way... As you said it is like
playing with *fire*.
To repeat: making identical entries in multiple places is a bad idea.
It may seem flexible, but the eventual trouble invariably exceeds any
perceived benefits.
As I'm a newbie at Excel... I dont' know whether it is impossible or
not.
I would like to know, can it be done? I know it is very much simple to
make a mirror of *two* sheets and both way updatable.
It's possible, but it *REQUIRES* programming/VBA.
For example, create a 3-column table named RefTbl in another worksheet
and fill it's first two columns with corresponding range addresses,
e.g., for 2 such ranges,
Sheet1!A1 Sheet2!B5
Sheet1!C3 Sheet2!B6
Make sure all cells in the 3rd column in this table are unprotected.
Then add the following event handler to the workbook's ThisWorkbook
class module.
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
Dim rt As Range, s As Range, wsa As String, k As Long
On Error GoTo Exit_Proc
Application.EnableEvents = False
Application.ScreenUpdating = False
Set rt = Me.Names("RefTbl").RefersToRange
wsa = Target.Parent.Name & "!" & Target.Address(0, 0, xlA1, 0)
With Application.WorksheetFunction
If .CountIf(.Index(rt, 0, 1), wsa) > 0 Then
k = .Match(wsa, .Index(rt, 0, 1), 0)
ElseIf .CountIf(.Index(rt, 0, 2), wsa) > 0 Then
k = .Match(wsa, .Index(rt, 0, 2), 0)
Else
k = 0
End If
If k > 0 Then
Set s = .Index(rt, k, 3)
s.Value = Target.Value
Range(.Index(rt, k, 1).Value).Formula = "=" & s.Address(1, 1,
xlA1, 1)
Range(.Index(rt, k, 2).Value).Formula = "=" & s.Address(1, 1,
xlA1, 1)
End If
End With
Exit_Proc:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
The value of whatever you enter in any of the cells listed in the 1st 2
columns of RefTbl will be stored in the 3rd column of RefTbl and the 2
corresponding cells will refer to the value in the 3rd column in
RefTbl.
Ain't there any ways to link two sheets and can be updated from the
both ends? Can't it be done using *Circular Reference*?
No, it can't be done using circular references.
Ponder this for a moment: if Sheet1!A1 contains the formula =Sheet2!B5,
and Sheet2!B5 contains the formula =Sheet1!A1, neither can contain the
value to which both should evaluate because they both need to contain
references to the other instead. That is, it's *IMPOSSIBLE* to store a
formula and a value in the same cell. If 2 cells should always evaluate
to the same value, then either one needs to hold the value and the
other refer to the former or both need to refer to a 3rd cell that
contains the common value.
There's NO WAY TO DO THIS without programming, so there's no SIMPLE way
to do this. Bemoan this fact it you will, keep asking for alternatives
if you must, but eventually you may realize that what you want to do
isn't simple.