Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Determine if a cell has datavalidation

Hi,

Is there anyway to determine if the cell has data validation defined ?.
Something similar to range.hasformula. I want to turn incelldropdown to
false if datavalidation is defined for the cell. I need this done to
prevent selection from the dropdown list of protected , locked cells
when the file has been opened in readonly.

Thank you.


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Determine if a cell has datavalidation

Sub testit()
Dim blnHasValidation As Boolean

On Error GoTo e
blnHasValidation = False
With ActiveCell.Validation: blnHasValidation = CBool(.Type = 0 Or .Type
< 0): End With
e: On Error GoTo 0

MsgBox blnHasValidation
End Sub


"mohsinb" wrote in message
...
Hi,

Is there anyway to determine if the cell has data validation defined ?.
Something similar to range.hasformula. I want to turn incelldropdown to
false if datavalidation is defined for the cell. I need this done to
prevent selection from the dropdown list of protected , locked cells
when the file has been opened in readonly.

Thank you.


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Determine if a cell has datavalidation

After putting brain in gear.. here's another solution:

Sub testit()
Dim blnHasValidation As Boolean

With ActiveSheet
blnHasValidation = Not
Intersect(.Cells.SpecialCells(xlCellTypeAllValidat ion), ActiveCell) Is
Nothing
End With

MsgBox blnHasValidation
End Sub


"Rob van Gelder" wrote in message
...
Sub testit()
Dim blnHasValidation As Boolean

On Error GoTo e
blnHasValidation = False
With ActiveCell.Validation: blnHasValidation = CBool(.Type = 0 Or

..Type
< 0): End With
e: On Error GoTo 0

MsgBox blnHasValidation
End Sub


"mohsinb" wrote in message
...
Hi,

Is there anyway to determine if the cell has data validation defined ?.
Something similar to range.hasformula. I want to turn incelldropdown to
false if datavalidation is defined for the cell. I need this done to
prevent selection from the dropdown list of protected , locked cells
when the file has been opened in readonly.

Thank you.


---
Message posted from http://www.ExcelForum.com/





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Determine if a cell has datavalidation

Thanks Rob.

I settled for a variation of the ''On Error" method to determine i
there is data validation for a cell. Works good. All set

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Determine if a cell has datavalidation

I think this might be another way:

Function HasValidation(rng As Range) As Boolean
On Error Resume Next
HasValidation = rng.Validation.AlertStyle
End Function

Debug.Print HasValidation(ActiveCell)
Debug.Print HasValidation(Range("B1"))

--
Dana DeLouis
= = = = = = = = = = = = = = = = =


"mohsinb" wrote in message
...
Hi,

Is there anyway to determine if the cell has data validation defined ?.
Something similar to range.hasformula. I want to turn incelldropdown to
false if datavalidation is defined for the cell. I need this done to
prevent selection from the dropdown list of protected , locked cells
when the file has been opened in readonly.

Thank you.



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
Filtering or Formatting DataValidation List Lost Cluster Excel Discussion (Misc queries) 6 June 5th 10 10:47 PM
DataValidation Check in cell of excel AmitAgarwal Excel Discussion (Misc queries) 3 July 20th 09 03:29 PM
datavalidation conditional list TUNGANA KURMA RAJU Excel Discussion (Misc queries) 0 March 28th 07 02:45 AM
datavalidation conditional list Toppers Excel Discussion (Misc queries) 1 March 28th 07 02:08 AM
Why the DataValidation Code not working? Soniya Excel Programming 0 August 14th 03 08:13 AM


All times are GMT +1. The time now is 09:01 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"