I have a certain range of cells in excel where I want to apply data validation on another data validation.
I want the user to only have 3 options for data input within range of cells:
- either a number,
- a range of numbers or by
- choosing from a dropdown list that contains words and numbers.
I already implemented number 1 and 2 with the following function:
Function checkStr(ByVal str As String) As String
Dim objRegEx As Object, allMatches As Object
Set objRegEx = CreateObject("VBScript.RegExp")
With objRegEx
.MultiLine = False
.IgnoreCase = False
.Global = True
.Pattern = "^\d+(-\d+)?$"
End With
Set allMatches = objRegEx.Execute(str)
checkStr = (allMatches.Count > 0)
End Function
Since the above function will only allow numbers or a range of numbers to be inputted, any ideas on how to add a validation to allow values from a pre-defined list containing both words and numbers?