@frswataru (本石 渉)

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

VBA セルの値が入力されたら実行する

Q&A

Closed

解決したいこと

VBA セルの値が入力されたらMsgを実行するようにしたいです
<条件>
Range("A1") に値が入力されたら -> MsgBox "こんにちは"
Range("B1") に値が入力されたら -> MsgBox "Hello"

該当するソースコード

Private Sub Worksheet_Change(ByVal Target As Range)
    If Cells(1, 1) <> Then
     MsgBox "こんにちは"
    End If
End Sub
Private Sub Worksheet_Change_2(ByVal Target As Range)
    If Cells(1, 2) <> Then
     MsgBox "Hello"
    End If
End Sub
0 likes

1Answer

これを参考に


Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A1")) Is Nothing Then
        MsgBox "こんにちは"
    ElseIf Not Intersect(Target, Range("B1")) Is Nothing Then
        MsgBox "Hello"
    End If
End Sub


1Like

Comments

  1. @frswataru

    Questioner

    ありがとうございます。参考します。

Your answer might help someone💌