Code to find data validation in a cell

D

DaveO

I'm trying to gin up the code to determine if a cell in a worksheet
validates data from a list and if yes, what list is in use. What I
have so far is:

sub Find_Val()
dim rCell as range

For Each rCell In ActiveSheet.UsedRange
If rCell.Validation.Type = xlValidateList Then MsgBox
rCell.Validation.Formula1
Next rCell

end sub

This generates an error. Can anyone suggest valide code to do this?
 
D

DaveO

Futzed with it some more, and this code will do it:

Sub Find_Validation()
Dim rCell As Range
On Error Resume Next
For Each rCell In ActiveSheet.UsedRange
If rCell.Validation.Type = xlValidateList _
Then MsgBox rCell.Validation.Formula1

Next rCell

End Sub

.... but is there a more direct or "elegant" way? The On Error Resume
Next seems like a cheap fix.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top