0

## Worksheet_Change 觸發問題

z89787 4 月前3311 瀏覽

``````Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.EnableEvents = False '暫時停止事件觸發
If Target.Column = 1 And Target.Row = 1 Then
ThisRow = Target.Row
If Target.Value < 100 Then
Range("B1").ClearContents
MsgBox ("hello")
Else
Range("B1") = "無"
End If
End If
Application.EnableEvents = True '啟用事件觸發
End Sub
``````

### 1 個回答

1

iT邦超人 1 級 ‧ 4 月前

``````If Target.Column = 1 And Target.Row = 1 Then
``````

``````Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.EnableEvents = False '暫時停止事件觸發
'    If Target.Column = 1 And Target.Row = 1 Then
'        ThisRow = Target.Row
'        If Target.Value = 1 Then
If Range("A1").Value = 1 Then
Range("B1").ClearContents
MsgBox ("hello")
Else
Range("B1") = "無"
End If
'    End If
Application.EnableEvents = True '啟用事件觸發
End Sub
``````

``````Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.EnableEvents = False '暫時停止事件觸發
'    If Target.Column = 1 And Target.Row = 1 Then
'        ThisRow = Target.Row
'        If Target.Value = 1 Then
If Range("A1").Value < 100 Then
Range("B1").ClearContents
MsgBox ("hello")
Else
Range("B1") = "無"
End If
'    End If
Application.EnableEvents = True '啟用事件觸發
End Sub
``````
z89787 iT邦新手 5 級 ‧ 4 月前 檢舉

z89787 iT邦新手 5 級 ‧ 4 月前 檢舉

Caculate 連 Target 這個參數都沒有

``````Private Sub Worksheet_Caculate
Application.EnableEvents = False '暫時停止事件觸發
'    If Target.Column = 1 And Target.Row = 1 Then
'        ThisRow = Target.Row
'        If Target.Value = 1 Then
If Range("A1").Value = 1 Then
Range("B1").ClearContents
MsgBox ("hello")
Else
Range("B1") = "無"
End If
'    End If
Application.EnableEvents = True '啟用事件觸發
End Sub
``````

z89787 iT邦新手 5 級 ‧ 4 月前 檢舉

``````Private Sub Worksheet_Caculate()
``````
z89787 iT邦新手 5 級 ‧ 4 月前 檢舉