Cate,
Garry's right, there are ways to access the validation rules. Here is a skeleton framework to generate a message box with the basic rule values for an active cell. It is very rough, but illustrates the concept. The macro starts by trying to find the validation type. An error means there is no validation rule on the active cell.
Next, it will find the type of rule on a list (search help for Validation.Type to see more details). Depending on the type of rule, there are three values that may be of interest: Operator, Formula1 and Formula2. The operator returns a number corresponding to a list of operators (1 = "between", 2 = "not between", etc.). I have included a function to find the operator based on this value. The Formula1 and Formula2 fields contain either values or formulas (such as low and high numbers or custom lists/formulas).
You will have to do a lot of customizing to have your macros work with this.. For example, you'll probably want to change this sub to a function that returns a boolean. In that case, you would include the value to check as apassed variable and use the "Select Case .Type" section to evaluate this value against the type of validation rule.
There may be an easier way, but the method below may work in a pinch.
Ben
Sub GetValidation()
Dim sMessage As String
On Error Resume Next
Debug.Print ActiveCell.Validation.Type
If Err.Number = 0 Then 'Cell has validation
On Error GoTo 0
With ActiveCell.Validation
Select Case .Type
Case 0 'Validate only when user changes the value
Case 1 'Whole numeric values
sMessage = "Whole numeric values " & _
GetOperator(.Operator) & " " & .Formula1 & " " & .Formula2
Case 2 'Numeric values
sMessage = "Numeric values " & _
GetOperator(.Operator) & " " & .Formula1 & " " & .Formula2
Case 3 'List
sMessage = "List of values: " & .Formula1
Case 4 'Date
sMessage = "Dates " & _
GetOperator(.Operator) & " " & .Formula1 & " " & .Formula2
Case 5 'Time
sMessage = "Times " & _
GetOperator(.Operator) & " " & .Formula1 & " " & .Formula2
Case 6 'Text Length
sMessage = "Text Length " & _
GetOperator(.Operator) & " " & .Formula1 & " " & .Formula2
Case 7 'Formula
sMessage = "Formula: " & .Formula1
End Select
End With
Else
'No validation rules present
sMessage = "No rules present"
Err.Clear
End If
MsgBox sMessage
End Sub
Function GetOperator(lType As Long) As String
Select Case lType
Case 1
GetOperator = "Between"
Case 2
GetOperator = "Not Between"
Case 3
GetOperator = "Equal To"
Case 4
GetOperator = "Not Equal To"
Case 5
GetOperator = "Greater Than"
Case 6
GetOperator = "Less Than"
Case 7
GetOperator = "Greater Than or Equal To"
Case 8
GetOperator = "Less Than or Equal To"
Case Else
GetOperator = vbNullString
End Select
End Function