Run macro based on cell value

Lukael

New member
Joined
Feb 9, 2014
Messages
21
Reaction score
0
Points
0
Hello,

I want to run a macro with msgbox ("This is correct!"), If A2 Cell has a value "KP". How can I do that ?


Please give me code for macro and Worksheet !


Regards, Luka
 
you can put this in the ThisWorkbook code.
It will trigger when the contents of cell A2 change

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If Target.Row = 2 And Target.Column = 1 Then
        If Target.Value = "KP" Then
            MsgBox ("This is correct!")
        End If
    End If
End Sub
 
you can put this in the ThisWorkbook code.
It will trigger when the contents of cell A2 change

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If Target.Row = 2 And Target.Column = 1 Then
        If Target.Value = "KP" Then
            MsgBox ("This is correct!")
        End If
    End If
End Sub

thanks, It works fine !!1
 
Back
Top