ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Change Event on a Specific Cell (https://www.excelbanter.com/excel-worksheet-functions/150981-change-event-specific-cell.html)

Sashi

Change Event on a Specific Cell
 
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!

JMB

Change Event on a Specific Cell
 
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


"Sashi" wrote:

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!


Sashi

Change Event on a Specific Cell
 
It worked, thank you so much! :)

JMB

Change Event on a Specific Cell
 
You're welcome. Thanks for the feedback.

"Sashi" wrote:

It worked, thank you so much! :)



All times are GMT +1. The time now is 04:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com