Check To See If A Cell Have Data Validation

markkramer

Board Regular
Joined
May 8, 2002
Messages
162
Hi!

Is there an expression that can be used to check to see if a cell has data validation associated with it? In psuedo-code, I'm looking to do this:

If Range("A1").Validation = False
msgbox("Hey! You got rid of the data validation!")
Endif
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Sub Test1()
On Error Resume Next
If ActiveCell.Validation.Type <> 0 Then
If Err.Number <> 0 Then
Err.Clear
MsgBox _
"Cell " & ActiveCell.Address(0, 0) & _
" does not have data validation.", _
48, "No DV here"
Else
MsgBox _
"Cell " & ActiveCell.Address(0, 0) & _
" has data validation.", _
64, "Seek and you shall find."
End If
End If
End Sub
 
Upvote 0
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myCol%
Dim myRow&

If Selection.Count > 1 Then Exit Sub

myCol = Target.Column
myRow = Target.Row

On Error GoTo myErr
If Not IsMissing(Cells(myRow, myCol).Validation.Operator) Then _
MsgBox "This cell has Data Validation!", vbInformation + vbOKOnly, "Data Validation!"
Exit Sub

myErr:

MsgBox "Hey! You got rid of the data validation!", vbExclamation + vbOKOnly, "Validation Error!"
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,540
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top