Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 427
Default VB syntax to test for data validation in a cell

I have inherited a workbook of questionable design- many named ranges,
for instance, that are used by dropdowns for data validation. I'd like
to go cell by cell and determine if data validation is used in that
cell, and if yes what named range is referenced.

I could make this work if the following code would run, but it
generates an error. This is the kind of cell-by-cell test I'd like to
perform. Can anyone suggest better syntax? Thanks!

Sub test()
Dim rCell As Range

For Each rCell In ActiveSheet.UsedRange
If rCell.Validation.InCellDropdown = True Then 'THIS LINE GENERATES
THE ERROR
MsgBox rCell.Address
End If
Next rCell

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default VB syntax to test for data validation in a cell

Nothing wrong with defined names!

Public Sub test()
Dim rCell As Range
Dim dvType

For Each rCell In ActiveSheet.UsedRange
dvType = 0
On Error Resume Next
dvType = rCell.Validation.Type
On Error GoTo 0
If dvType < 0 Then MsgBox rCell.Address
Next rCell

End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Dave O" wrote in message
oups.com...
I have inherited a workbook of questionable design- many named ranges,
for instance, that are used by dropdowns for data validation. I'd like
to go cell by cell and determine if data validation is used in that
cell, and if yes what named range is referenced.

I could make this work if the following code would run, but it
generates an error. This is the kind of cell-by-cell test I'd like to
perform. Can anyone suggest better syntax? Thanks!

Sub test()
Dim rCell As Range

For Each rCell In ActiveSheet.UsedRange
If rCell.Validation.InCellDropdown = True Then 'THIS LINE GENERATES
THE ERROR
MsgBox rCell.Address
End If
Next rCell

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 427
Default VB syntax to test for data validation in a cell

Thanks, Bob- you're right, nothing wrong with defined names: I'm just
trying to delete the redundant ones. I had an On Error Resume Next
line, but not the On Error GoTo 0. Thanks for the tip!

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
Validation Data using Validation Table cell range..... Dermot Excel Discussion (Misc queries) 16 January 5th 10 09:35 PM
Test in Validation Box Very Small Font Size... cdavidson Excel Discussion (Misc queries) 1 May 18th 07 08:51 PM
Data Validation: Store cell address instead of value in the cell? WillW Excel Discussion (Misc queries) 1 January 31st 07 02:22 AM
Why does data validation not work when pasting data into a cell. rjshelby Excel Discussion (Misc queries) 1 July 31st 06 09:08 PM
Data Validation Syntax Question Jim & Gail Excel Discussion (Misc queries) 2 April 7th 05 04:17 AM


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

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"