Hello,
I am hoping one of you experts can help me solve this. I am trying to add a worksheet change selection to delete the current data validation input message on this specific selected cell (K7). Then add a new one. The reason for this, is the conditions might change based on other cells so I want the currently input message to be deleted and the valid one be entered. This is my code:
However, it doesn't work. I have added Application.EnableEvents = True to the immediate window, saved and closed. It still doesn't work. If I mess with the code, and run it line by line in another module. It works. But not if I simply select K7 like the code should run just by the selection. Any help would be much appreciated! Thank you!
I am hoping one of you experts can help me solve this. I am trying to add a worksheet change selection to delete the current data validation input message on this specific selected cell (K7). Then add a new one. The reason for this, is the conditions might change based on other cells so I want the currently input message to be deleted and the valid one be entered. This is my code:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As range)
Dim ws As Worksheet
Application.EnableEvents = False
Set ws = Sheets("Status of Closing")
If Target.Address = ws.range("K7") Then
With ws.range("K7").Validation
.Delete
.Add Type:=xlValidateInputOnly
.InputTitle = "Escrow Calculations:"
.InputMessage = ws.range("Ap5").value & Space(10) & Space(10) & "Tax Installments: " & ws.range("AR3").value & ws.range("AS3").value & Space(10) & ws.range("AT3").value & ws.range("AU3").value
End With
Else
ws.range("K7").Validation.Delete
End If
Application.EnableEvents = True
End Sub
However, it doesn't work. I have added Application.EnableEvents = True to the immediate window, saved and closed. It still doesn't work. If I mess with the code, and run it line by line in another module. It works. But not if I simply select K7 like the code should run just by the selection. Any help would be much appreciated! Thank you!