Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation Data using Validation Table cell range..... Dermot Excel Discussion (Misc queries) 16 January 5th 10 09:35 PM
VB syntax to test for data validation in a cell Dave O Excel Discussion (Misc queries) 2 July 26th 07 09:29 PM
Test in Validation Box Very Small Font Size... cdavidson Excel Discussion (Misc queries) 1 May 18th 07 08:51 PM
Calculate mean of test scores from rows of test answers RiotLoadTime Excel Discussion (Misc queries) 1 July 26th 06 05:14 PM
How can i test a cell for bold style in a cell (Excel 2003)? Mike A. Excel Worksheet Functions 2 March 6th 06 07:23 PM


All times are GMT +1. The time now is 08:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"