VBA code required for Msg Box when two value equal in two cells

Try this:

Private Sub Worksheet_Change(ByVal Target As Range)        
    If Range("A" & Target.Row) = Range("B" & Target.Row) Then
        MsgBox "Buy - " & Range("E" & Target.Row)
    ElseIf Range("A" & Target.Row) = Range("C" & Target.Row) Then
        MsgBox "Sell - " & Range("E" & Target.Row)
    End If
End Sub

The key is using the Worksheet_Change event in the worksheet where you have your data.

Leave a Comment