|
楼主 |
发表于 2020-1-13 23:08
|
显示全部楼层
我已找到方法,送给有需要的人
Sheet1 :Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$1" And Target.Address <> "$B$1" Then Exit Sub
Application.EnableEvents = False
If Worksheets("Sheet1").Cells(1, 1).Value <> "" Then Worksheets("Sheet2").Cells(1, 1).Value = Worksheets("Sheet1").Cells(1, 1).Value
If Worksheets("Sheet2").Cells(1, 1).Value <> "" Then Worksheets("Sheet1").Cells(1, 1).Value = Worksheets("Sheet2").Cells(1, 1).Value
Application.EnableEvents = True
End Sub
Sheet 2 :
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$1" And Target.Address <> "$B$1" Then Exit Sub
Application.EnableEvents = False
If Worksheets("Sheet2").Cells(1, 1).Value <> "" Then Worksheets("Sheet1").Cells(1, 1).Value = Worksheets("Sheet2").Cells(1, 1).Value
If Worksheets("Sheet1").Cells(1, 1).Value <> "" Then Worksheets("Sheet2").Cells(1, 1).Value = Worksheets("Sheet1").Cells(1, 1).Value
Application.EnableEvents = True
End Sub |
|