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

I want to read the Formula1 property of a validation object of the cell Target.
Target.Validation.Formula1 produces an "Application-defined or
object-defined error" if Target don't have a validation rule.
How cant I check whether a validation list is defined?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Validation Object error

Something like this:

Sub AABB()
Dim s As String
Set target = ActiveCell
s = ""
On Error Resume Next
s = target.Validation.Formula1
On Error GoTo 0
If s < "" Then
MsgBox s
Else
MsgBox "No validation"
End If
End Sub


--
Regards,
Tom Ogilvy


"Peter Zinniker" wrote:

I want to read the Formula1 property of a validation object of the cell Target.
Target.Validation.Formula1 produces an "Application-defined or
object-defined error" if Target don't have a validation rule.
How cant I check whether a validation list is defined?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Validation Object error

Uff, not very elegant coding.
Anyway thank you very much for the hint.
Peter

"Tom Ogilvy" wrote:

Something like this:

Sub AABB()
Dim s As String
Set target = ActiveCell
s = ""
On Error Resume Next
s = target.Validation.Formula1
On Error GoTo 0
If s < "" Then
MsgBox s
Else
MsgBox "No validation"
End If
End Sub


--
Regards,
Tom Ogilvy


"Peter Zinniker" wrote:

I want to read the Formula1 property of a validation object of the cell Target.
Target.Validation.Formula1 produces an "Application-defined or
object-defined error" if Target don't have a validation rule.
How cant I check whether a validation list is defined?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Validation Object error


If target.Validation.Value = True Then
target.Validation.Formula1
End If

"Peter Zinniker" wrote:

I want to read the Formula1 property of a validation object of the cell Target.
Target.Validation.Formula1 produces an "Application-defined or
object-defined error" if Target don't have a validation rule.
How cant I check whether a validation list is defined?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Validation Object error

I would disagree.

Let's see your elegant approach.

--
regards,
Tom Ogilvy


"Peter Zinniker" wrote:

Uff, not very elegant coding.
Anyway thank you very much for the hint.
Peter

"Tom Ogilvy" wrote:

Something like this:

Sub AABB()
Dim s As String
Set target = ActiveCell
s = ""
On Error Resume Next
s = target.Validation.Formula1
On Error GoTo 0
If s < "" Then
MsgBox s
Else
MsgBox "No validation"
End If
End Sub


--
Regards,
Tom Ogilvy


"Peter Zinniker" wrote:

I want to read the Formula1 property of a validation object of the cell Target.
Target.Validation.Formula1 produces an "Application-defined or
object-defined error" if Target don't have a validation rule.
How cant I check whether a validation list is defined?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Validation Object error

That seems to return true for every cell (whether they have validation or
not) except cells that have validation and the value in the cell doesn't
match the validation criteria.

--
Regards,
Tom Ogilvy

"Joel" wrote:


If target.Validation.Value = True Then
target.Validation.Formula1
End If

"Peter Zinniker" wrote:

I want to read the Formula1 property of a validation object of the cell Target.
Target.Validation.Formula1 produces an "Application-defined or
object-defined error" if Target don't have a validation rule.
How cant I check whether a validation list is defined?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Validation Object error

Joel
Thank you for the answer but it does not solve my problem:
The Value property is TRUE even if there is no validation rule defined.
"Help" says: TRUE if all the validation criteria are met (that is, if the
range contains valid data)
Regards, Peter

"Joel" wrote:


If target.Validation.Value = True Then
target.Validation.Formula1
End If

"Peter Zinniker" wrote:

I want to read the Formula1 property of a validation object of the cell Target.
Target.Validation.Formula1 produces an "Application-defined or
object-defined error" if Target don't have a validation rule.
How cant I check whether a validation list is defined?

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Validation Object error

None found so far.
I will (heavyheartedly) use your code.
No offence! Have a nice day!
Peter

"Tom Ogilvy" wrote:

I would disagree.

Let's see your elegant approach.

--
regards,
Tom Ogilvy


"Peter Zinniker" wrote:

Uff, not very elegant coding.
Anyway thank you very much for the hint.
Peter

"Tom Ogilvy" wrote:

Something like this:

Sub AABB()
Dim s As String
Set target = ActiveCell
s = ""
On Error Resume Next
s = target.Validation.Formula1
On Error GoTo 0
If s < "" Then
MsgBox s
Else
MsgBox "No validation"
End If
End Sub


--
Regards,
Tom Ogilvy


"Peter Zinniker" wrote:

I want to read the Formula1 property of a validation object of the cell Target.
Target.Validation.Formula1 produces an "Application-defined or
object-defined error" if Target don't have a validation rule.
How cant I check whether a validation list is defined?

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
runtime error '1004' application or object defined error Janis Excel Programming 4 November 18th 09 03:01 PM
Run Time Error 1004: Application or Object Defined Error BEEJAY Excel Programming 4 October 18th 06 04:19 PM
Object Variable Not Set Error on Selection object Jean Excel Worksheet Functions 3 July 24th 06 06:45 PM
Error 1004, Application-definded or object-defined error Mirco Wilhelm[_2_] Excel Programming 9 January 7th 06 04:56 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM


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