ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Code to find data validation in a cell (https://www.excelbanter.com/excel-discussion-misc-queries/135431-code-find-data-validation-cell.html)

DaveO[_2_]

Code to find data validation in a cell
 
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?


DaveO[_2_]

Code to find data validation in a cell
 
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.




All times are GMT +1. The time now is 04:52 PM.

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