Change Event on a Specific Cell

S

Sashi

I'm using data validation on one cell, say C19. Is there a pre-defined event
that we can use so that when there is a change on this specific cell it will
prompt the user for a password?

I'm new, I already have this code: (but it's not working)

Private Sub Worksheet_Change(ByVal C19 As Range)
Set pass = Application.InputBox(prompt:="Enter a Password", Type:=2)
End Sub

I found events only on workbook and worksheet but nothing on a specific
cell. Do you think this is possible? Help!
 
J

JMB

Check VBA help for the Intersect method. Maybe you are looking for something
along the lines of:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("C19")) Is Nothing Then
pass = Application.InputBox(prompt:="Enter a Password", Type:=2)
If pass <> YourPassword Then Application.Undo
End If
End Sub
 
Top