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

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,257
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
 

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
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
 

Forum statistics

Threads
1,141,743
Messages
5,708,243
Members
421,554
Latest member
aichabaddi

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
Top