Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Using Validation.Type on a Range

I can do the following...
If Selection.Validation.Type = xlValidateList Then
Else
End If

Why can't I use...

If Worksheets(1).Cells(7,1).Validation.Type = xlValidateList Then
Else
End If

I am using Office 2003

Thanks,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Using Validation.Type on a Range

Actually they both work but only if the cell you reference or select has
validation applied. Any other cell will cause an error. When testing a
cell or range, you need to check if there is ANY validation first then
determine it type. See the following code as an example. Do not forget to
set the error trapping in your VBE to break on unhandled errors.

On Error Resume Next
With Range("B3")
x = .Validation.Type
If Err.Number = 0 Then
If x = 3 Then
MsgBox "Validation - is a list"
Else
MsgBox "Validation - not a list"
End If
Else
MsgBox "No validation"
End If
End With
On Error GoTo 0

--

Regards,
Nigel




"blisspikle" wrote in message
...
I can do the following...
If Selection.Validation.Type = xlValidateList Then
Else
End If

Why can't I use...

If Worksheets(1).Cells(7,1).Validation.Type = xlValidateList Then
Else
End If

I am using Office 2003

Thanks,


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Using Validation.Type on a Range

Thank you,

Seems kind of silly, when you go into a cell not using validation and
open Validation Form it has "Any Value" in the Allow Combobox, so I
just assumed that validation was on in every cell, but allowing "any
value". Anyways, thank you for the answer.




On Jan 8, 12:44*am, "Nigel" wrote:
Actually they both work but only if the cell you reference or select has
validation applied. *Any other cell will cause an error. *When testing a
cell or range, you need to check if there is ANY validation first then
determine it type. *See the following code as an example. *Do not forget to
set the error trapping in your VBE to break on unhandled errors.

* *On Error Resume Next
* * With Range("B3")
* * * *x = .Validation.Type
* * * *If Err.Number = 0 Then
* * * * *If x = 3 Then
* * * * * *MsgBox "Validation - is a list"
* * * * *Else
* * * * * *MsgBox "Validation - not a list"
* * * * *End If
* * * *Else
* * * * * MsgBox "No validation"
* * * *End If
* * End With
* * On Error GoTo 0

--

Regards,
Nigel


"blisspikle" wrote in message

...



I can do the following...
* *If Selection.Validation.Type = xlValidateList Then
* *Else
* *End If


Why can't I use...


* *If Worksheets(1).Cells(7,1).Validation.Type = xlValidateList Then
* *Else
* *End If


I am using Office 2003


Thanks,- Hide quoted text -


- Show quoted text -


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
Field Validation for Length & Character Type Rob Excel Discussion (Misc queries) 3 September 20th 07 01:11 PM
Data validation list type hshayhorn Excel Programming 2 September 19th 07 09:29 PM
Data Validation type query [email protected] Excel Programming 2 March 7th 07 03:20 PM
Type mismatch using rnge as Range with Type 8 Input Box STEVE BELL Excel Programming 11 December 3rd 05 05:02 AM
Drop Down Menu (non Data Validation type) blc[_2_] Excel Programming 1 January 20th 04 12:31 AM


All times are GMT +1. The time now is 10:14 AM.

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"