|
楼主 |
发表于 2020-1-13 23:08
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
我已找到方法,送给有需要的人
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 |
|