gyetvaig

VBA Check if a cell has data validation

Jan 16th, 2019
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' ----------------------------------------------------------------
  2. ' Purpose: Check if a cell has data validation or not
  3. ' ----------------------------------------------------------------
  4. Function f_cellHasValidation(cell As Range) As Boolean
  5.  
  6.     Dim valType As Long
  7.  
  8.     f_cellHasValidation = True
  9.  
  10.     On Error Resume Next
  11.    
  12.     valType = cell.Validation.Type
  13.  
  14.     If Err.Number <> 0 Then
  15.         f_cellHasValidation = False
  16.     End If
  17.    
  18.     On Error GoTo 0
  19.    
  20. End Function
Advertisement