Excel 鼠标离开单元格触发事件

2025-01-07 14:53:43
推荐回答(2个)
回答1:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim s
If Target.Row = 4 And Target.Column = 6 Then
If Target.Value <> Cells(4, 1) * Cells(4, 3) Then
s = MsgBox("现在修改的值可能不正确,是否需要继续修改。如果确定继续修改就点击确认,如果不继续修改就点击取消。", vbAbortRetryIgnore)
If s = 3 Then Exit Sub
If s = 4 Then Target.Activate
If s = 5 Then Cells(4, 6) = "=A4*C4"
End If
End If
End Sub

回答2:

Private Sub Worksheet_Change(ByVal Target As Range)
dim str ,a
str=[a4]*[c4]
if target.row=4 and target.column=6 then
if [f4]<>str then a=msgbox ("是否需要继续修改",vbyesyno)
if a=vbyes then
else
[f4]=str
end if
else
end if
end sub