Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Testing for Cell Validation


For a newby to VBA programing; anyone know a neat way of testing in VB
if a cell has data validation turned on.

Have only been able to test with an error trap on Validation.Type


Dunca

--
djrfor
-----------------------------------------------------------------------
djrforb's Profile: http://www.excelforum.com/member.php...fo&userid=1486
View this thread: http://www.excelforum.com/showthread.php?threadid=26492

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Testing for Cell Validation

Dim cell as Range
set cell = Range("B9")
If not intersect(Cell, Cells.SpecialCells(xlCellTypeAllValidation)) is
nothing then
msgbox Cell.Address & " contains data validation"
Else
msgbox cCell.Addres & " does not contain data validation"
End if

--
Regards,
Tom Ogilvy


"djrforb" wrote in message
...

For a newby to VBA programing; anyone know a neat way of testing in VBA
if a cell has data validation turned on.

Have only been able to test with an error trap on Validation.Type


Duncan


--
djrforb
------------------------------------------------------------------------
djrforb's Profile:

http://www.excelforum.com/member.php...o&userid=14863
View this thread: http://www.excelforum.com/showthread...hreadid=264928



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default Testing for Cell Validation

Tom:
I got this working IF TRUE, but IF FALSE I get
RT error 1004
No cells were found, <<On the Intersect() line.
Any Suggestions?
Jim

"Tom Ogilvy" wrote in message
...
Dim cell as Range
set cell = Range("B9")
If not intersect(Cell, Cells.SpecialCells(xlCellTypeAllValidation)) is
nothing then
msgbox Cell.Address & " contains data validation"
Else
msgbox cCell.Addres & " does not contain data validation"
End if

--
Regards,
Tom Ogilvy


"djrforb" wrote in message
...

For a newby to VBA programing; anyone know a neat way of testing in VBA
if a cell has data validation turned on.

Have only been able to test with an error trap on Validation.Type


Duncan


--
djrforb
------------------------------------------------------------------------
djrforb's Profile:

http://www.excelforum.com/member.php...o&userid=14863
View this thread:

http://www.excelforum.com/showthread...hreadid=264928





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Testing for Cell Validation

Hi Jim,

Tom was demonstrating a technique rather than supplying final code.
Tom has pointed out many times to others that the SpecialCells method
throws an error if no cells are found. Had this been production code, Tom
would have trapped the resultant error.

Try:

Dim cell As Range, Rng As Range
Set cell = Range("B9")

On Error Resume Next
Set Rng = Intersect(cell, Cells. _
SpecialCells(xlCellTypeAllValidation))
On Error GoTo 0

If Not Rng Is Nothing Then
MsgBox cell.Address & " contains data validation"
Else
MsgBox cell.Address & " does not contain data validation"
End If


---
Regards,
Norman



"Jim May" wrote in message
news:t%O6d.4037$Hz.814@fed1read04...
Tom:
I got this working IF TRUE, but IF FALSE I get
RT error 1004
No cells were found, <<On the Intersect() line.
Any Suggestions?
Jim

"Tom Ogilvy" wrote in message
...
Dim cell as Range
set cell = Range("B9")
If not intersect(Cell, Cells.SpecialCells(xlCellTypeAllValidation)) is
nothing then
msgbox Cell.Address & " contains data validation"
Else
msgbox cCell.Addres & " does not contain data validation"
End if

--
Regards,
Tom Ogilvy


"djrforb" wrote in message
...

For a newby to VBA programing; anyone know a neat way of testing in VBA
if a cell has data validation turned on.

Have only been able to test with an error trap on Validation.Type


Duncan


--
djrforb
------------------------------------------------------------------------
djrforb's Profile:

http://www.excelforum.com/member.php...o&userid=14863
View this thread:

http://www.excelforum.com/showthread...hreadid=264928







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default Testing for Cell Validation

Norman,
Thanks for taking the time to get into this;
I used your code and am "error-free"...
Jim May


"Norman Jones" wrote in message
...
Hi Jim,

Tom was demonstrating a technique rather than supplying final code.
Tom has pointed out many times to others that the SpecialCells method
throws an error if no cells are found. Had this been production code, Tom
would have trapped the resultant error.

Try:

Dim cell As Range, Rng As Range
Set cell = Range("B9")

On Error Resume Next
Set Rng = Intersect(cell, Cells. _
SpecialCells(xlCellTypeAllValidation))
On Error GoTo 0

If Not Rng Is Nothing Then
MsgBox cell.Address & " contains data validation"
Else
MsgBox cell.Address & " does not contain data validation"
End If


---
Regards,
Norman



"Jim May" wrote in message
news:t%O6d.4037$Hz.814@fed1read04...
Tom:
I got this working IF TRUE, but IF FALSE I get
RT error 1004
No cells were found, <<On the Intersect() line.
Any Suggestions?
Jim

"Tom Ogilvy" wrote in message
...
Dim cell as Range
set cell = Range("B9")
If not intersect(Cell, Cells.SpecialCells(xlCellTypeAllValidation)) is
nothing then
msgbox Cell.Address & " contains data validation"
Else
msgbox cCell.Addres & " does not contain data validation"
End if

--
Regards,
Tom Ogilvy


"djrforb" wrote in message
...

For a newby to VBA programing; anyone know a neat way of testing in

VBA
if a cell has data validation turned on.

Have only been able to test with an error trap on Validation.Type


Duncan


--
djrforb

------------------------------------------------------------------------
djrforb's Profile:
http://www.excelforum.com/member.php...o&userid=14863
View this thread:

http://www.excelforum.com/showthread...hreadid=264928











  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Testing for Cell Validation

I think this might be another option as a function:

Function HasValidationQ(rng As Range) As Boolean
On Error Resume Next
HasValidationQ = rng.Validation.Type = 0
End Function

Debug.Print HasValidationQ([A1])

--
Dana DeLouis
Win XP & Office 2003


"djrforb" wrote in message
...

For a newby to VBA programing; anyone know a neat way of testing in VBA
if a cell has data validation turned on.

Have only been able to test with an error trap on Validation.Type


Duncan


--
djrforb
------------------------------------------------------------------------
djrforb's Profile:
http://www.excelforum.com/member.php...o&userid=14863
View this thread: http://www.excelforum.com/showthread...hreadid=264928



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
testing for a value in a cell Dave Eade Excel Discussion (Misc queries) 1 February 11th 10 11:54 AM
Testing a cell value Finance Guru Excel Worksheet Functions 2 January 19th 09 12:44 PM
Testing a cell Michael Singmin Excel Programming 5 November 29th 03 05:56 AM
testing cell value Thompson, Joseph Excel Programming 1 November 8th 03 09:41 AM
testing the value of a cell Zeraia Excel Programming 3 October 22nd 03 12:58 AM


All times are GMT +1. The time now is 09:46 PM.

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

About Us

"It's about Microsoft Excel"