PrivateSub Worksheet_SelectionChange(ByVal Target As Range) If Target.Count = 1 Then If Target.Address = "$G$2" Then If MsgBox("是否重置数据?", vbYesNo) = vbYes Then Dim MyCell As Range Application.ScreenUpdating = False ForEach MyCell In UsedRange If MyCell.Interior.ColorIndex = 36 Then MyCell = "" Next [d2:e2].ClearContents Application.ScreenUpdating = True ExitSub EndIf EndIf If Target.Address = "$F$2" Then IfNot PreCell IsNothingThen If MsgBox("恢复点击前数据吗?", vbYesNo) = vbYes Then  reCell = PreCell - 1 ExitSub EndIf EndIf EndIf If Target.Interior.ColorIndex = 36 Then Target = Target + 1 Set PreCell = Target EndIf EndIf EndSub
PrivateSub Worksheet_SelectionChange(ByVal Target As Range) If Target.Count = 1 Then If Target.Address = "$G$2" Then If MsgBox("是否重置数据?", vbYesNo) = vbYes Then Dim MyCell As Range Application.ScreenUpdating = False ForEach MyCell In UsedRange If MyCell.Interior.ColorIndex = 36 Then MyCell = "" Next [d2:e2].ClearContents Application.ScreenUpdating = True ExitSub EndIf EndIf If Target.Address = "$F$2" Then IfNot PreCell IsNothingThen If MsgBox("恢复点击前数据吗?", vbYesNo) = vbYes Then  reCell = PreCell - 1 ExitSub EndIf EndIf EndIf If Target.Interior.ColorIndex = 36 Then Target = Target + 1 Set PreCell = Target EndIf EndIf EndSub