2015-02-09 53 views
1

所以,在每一個表改變價值觀念和保持價值每片

Sheet1 "A1" 
Sheet2 "A1" 
Sheet3 "A1" 

現在我想,所有這些表共享相同的值的信息,並不重要價值。 但我必須能夠在每張紙上更改此值。 例如:該值是20。

Sheet1 A1's value = 20 

Sheet2 A1's value = 20 

Sheet3 A1's value = 20 

現在我有片材2上開口,我改變20〜30

Sheet1 A1's value = now 30 

Sheet2 A1's value = now 30 

Sheet3 A1's value = now 30 

然後,我注意到片3別的東西,並更改該值以50

Sheet1 A1's value = now 50 

Sheet2 A1's value = now 50 

Sheet3 A1's value = now 50 

至於最後一件事我回到表1,我看到,我做了一個計算錯誤,而不是50它必須是40所以我的值更改爲40

Sheet1 A1's value = now 40 

Sheet2 A1's value = now 40 

Sheet3 A1's value = now 40 

我該怎麼做?我試圖把這個在每片:

Private sub Worksheet_Change (Byval target as range) 

但只要我得到3張以上,"this function is not defined"

我搜索了像4小時上網了。我嘗試了不同的事情,但我無法做到。根據需要爲每個表

+0

您想要什麼? – 2015-02-09 13:47:40

+0

請使用'Worksheet_Change'發佈你的代碼 – 2015-02-09 14:02:12

回答

0

更改sheet

Private Sub Worksheet_Change(ByVal Target As Excel.Range) 
    If Target.Cells(1, 1) Then 
    sheet2.Cells(1, 1) = Cells(1, 1) 
    sheet3.Cells(1, 1) = Cells(1, 1) 
    sheet4.Cells(1, 1) = Cells(1, 1) 
    End If 
End Sub 
0

很簡單,只是迫使Worksheet_Change事件每個跟蹤表的內部價值的變化:

Private Sub Worksheet_Change(ByVal Target As Range) '<-- in Sheet 1 
    Sheets("Sheet2").Cells(Target.Row, Target.Column).Value = Target.Value 
    Sheets("Sheet3").Cells(Target.Row, Target.Column).Value = Target.Value 
End Sub 

Private Sub Worksheet_Change(ByVal Target As Range) '<-- in Sheet 2 
    Sheets("Sheet1").Cells(Target.Row, Target.Column).Value = Target.Value 
    Sheets("Sheet3").Cells(Target.Row, Target.Column).Value = Target.Value 
End Sub 

Private Sub Worksheet_Change(ByVal Target As Range) '<-- in Sheet 3 
    Sheets("Sheet1").Cells(Target.Row, Target.Column).Value = Target.Value 
    Sheets("Sheet2").Cells(Target.Row, Target.Column).Value = Target.Value 
End Sub 

P.s.以上內容將改變三張表格中的每個單元格。如果您只想更新A1,您需要添加一張支票,這意味着:

If Target.Address = "$A$1" Then 
    'change values 
End If