ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I check if a cell has a dropdown (https://www.excelbanter.com/excel-programming/392266-how-do-i-check-if-cell-has-dropdown.html)

Givnik

How do I check if a cell has a dropdown
 
I am validating a spreadsheet checking a range of cells and need to validate
that all the cells in the range has a dropdown associated with it. Any ideas
what the code is to do this.....

Peter T

How do I check if a cell has a dropdown
 
Sub test()
Dim nValType As Long
Dim rng As Range, cel As Range

Set rng = Selection

On Error Resume Next
For Each cel In rng
nValType = 0
nValType = cel.Validation.Type ' error if not validation

If nValType = 0 Then
' no validation
ElseIf nValType = xlValidateList Then
' dropdown list
Else
' some other validation
End If
Next

End Sub

Regards,
Peter T
"Givnik" wrote in message
...
I am validating a spreadsheet checking a range of cells and need to

validate
that all the cells in the range has a dropdown associated with it. Any

ideas
what the code is to do this.....




Givnik

How do I check if a cell has a dropdown
 
Hi Peter T,

Thanks for the code, it worked great.

Appreciate the help





"Peter T" wrote:

Sub test()
Dim nValType As Long
Dim rng As Range, cel As Range

Set rng = Selection

On Error Resume Next
For Each cel In rng
nValType = 0
nValType = cel.Validation.Type ' error if not validation

If nValType = 0 Then
' no validation
ElseIf nValType = xlValidateList Then
' dropdown list
Else
' some other validation
End If
Next

End Sub

Regards,
Peter T
"Givnik" wrote in message
...
I am validating a spreadsheet checking a range of cells and need to

validate
that all the cells in the range has a dropdown associated with it. Any

ideas
what the code is to do this.....






All times are GMT +1. The time now is 11:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com