I know this question is old, but since it appears when Googling โexcel vba checks if the cell has validationโ, I decided that I would add my own grain of salt.
If the Range
object you call SpecialCells
on represents only one cell, the entire sheet will be scanned to find matches. If you have a very large amount of data, the methods given in the previous answers may slow down a bit.
Therefore, here is a more efficient way to check if a single cell has validation:
Function HasValidation(cell As Range) As Boolean Dim t: t = Null On Error Resume Next t = cell.Validation.Type On Error GoTo 0 HasValidation = Not IsNull(t) End Function
source share