Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default VB Data Validation check

Hi all,
I am trying to find a way to check if a data validated cell contains invalid
data.

I know I can conditionally format it and that I can set Excel to Circle
Invalid Data but I want to check the validation status in VBA.

I was hoping that the following statement would return TRUE if the data was
invalid but it doesn't ..

mycell = activecell.Errors.Item(xlListDataValidation).value

I suppose another way would be to tell when Excel has circled the invalid
data. I know the command

activesheet.CircleInvalid

enables this but for the life of me, I can't find a property in
cells.validation that reflects the status.

Anyone have any ideas?

Grateful thanks as always!

Bony
--
"There are 10 types of people in this world. Those who understand Binary
and those who don''t ..."
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 236
Default VB Data Validation check

Perhaps there is a better way but you can try playing around with
Evaluate method.

A dummy sample:
This is the formula validation for H11:
=H11="a"

'Code:
Sub CheckValidation()
Dim rng As Range
Set rng = Range("H11")
With rng
If Evaluate(.Validation.Formula1) = True Then
Debug.Print "Validation passed"
Else
Debug.Print "Validation breached"
End If
End With
End Sub

So, if the value in H11=a, the code prints "Validation passed" else it
prints "Validation breached".

I don't know how complex your validations are but you can try this one
out.
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
data validation invalid in dynamic validation list ilia Excel Discussion (Misc queries) 0 November 7th 06 12:54 PM
data validation invalid in dynamic validation list ilia Excel Worksheet Functions 0 November 7th 06 12:54 PM
Data validation with validation lists and combo boxs Keith Excel Discussion (Misc queries) 1 October 12th 06 11:08 AM
Problem with validation check! Neo1 Excel Worksheet Functions 4 March 19th 06 03:28 AM
Check Boxes & Data Validation Mike R Excel Discussion (Misc queries) 4 October 4th 05 06:47 PM


All times are GMT +1. The time now is 12:30 AM.

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"