Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I check if the cell contains Validation type or not 1

Status
Not open for further replies.

yarondavid

Programmer
May 8, 2006
20
IL
Hi

I want to know how to insert an If statement that check if the specific cell contains a Validation type or not.

I get an error message with this statement:
If Range("B3").Validation Then
End If

thanks,
Yaron
 
I don't know the exact code that would do that but you could try to change one of the non-core properties of your validation which will cause an error if there is no valdation there. For example :

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub test()

'see if B3 contains a validation (TRUE/False)
msgbox CheckValidation (Range("B3"))

end sub


Private Function CheckValidation(rng As Range) As Boolean

On Error GoTo NoValidation
'try to change one of the properites
rng.Validation.IgnoreBlank = True
'no error - validation
CheckValidation = True

Exit Function

'error
NoValidation:
CheckValidation = False

End Function

''''''''''''''''''''''''''''''''''''''''''''''''''''''

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top