Test if cell.validation is set
Dear All,
This codeline triggers an error if no validation is set (any value) If ActiveCell.Validation.Type = xlValidateList Then How can I first test if validation is set ? If 'ActiveCell.valudation is set ' then If ActiveCell.Validation.Type = xlValidateList Then ..................code........................ end if end if Thanks, Filips |
Test if cell.validation is set
'-----------------------------------------------------------------
Public Function HasValidation(r As Range) As Boolean '----------------------------------------------------------------- Dim i Dim ma As Range On Error Resume Next HasValidation = True i = r.Validation.Type If Err.Number < 0 Then HasValidation = False Exit Function End If Set ma = r.MergeArea If ma.Cells(1, 1).Address < r.Address Then HasValidation = False End If End Function -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Filips Benoit" wrote in message ... Dear All, This codeline triggers an error if no validation is set (any value) If ActiveCell.Validation.Type = xlValidateList Then How can I first test if validation is set ? If 'ActiveCell.valudation is set ' then If ActiveCell.Validation.Type = xlValidateList Then ..................code........................ end if end if Thanks, Filips |
Test if cell.validation is set
Found this using Google:
One way: Dim mycel As Range Dim vald As Variant Set mycel = Range("D2") On Error Resume Next vald = mycel.Validation.Type On Error GoTo 0 If vald < Empty Then MsgBox "yes the cell have validation" Else MsgBox "no no, the cell is general." End If Hope this helps Rowan Drummond HTH - Jim May "Filips Benoit" wrote in message : Dear All, This codeline triggers an error if no validation is set (any value) If ActiveCell.Validation.Type = xlValidateList Then How can I first test if validation is set ? If 'ActiveCell.valudation is set ' then If ActiveCell.Validation.Type = xlValidateList Then ..................code........................ end if end if Thanks, Filips |
All times are GMT +1. The time now is 04:30 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com