I continue to get a syntax error with the following code. It doesn't seem to like my formula, even though it works when I just paste it in the custom data validation.
Formula:
=IF(B3="",TRUE,IF(ISERROR(SUMPRODUCT(SEARCH(MID(B3,ROW(INDIRECT("15:"&LEN(B3))),15),"0123456789"&"abcdefghijklmnopqrstuvwxyz"))),FALSE,TRUE))
VBA Code:
Public Sub Class_Initialize()
'Dim Range As String
With Range("e5").Validation
.Add Type:=xlValidateCustom, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="=IF(B3="",TRUE,IF(ISERROR(SUMPRODUCT(SEARCH(MID(B3,ROW(INDIRECT("15:"&LEN(B3))),15),"0123456789"&"abcdefghijklmnopqrstuvwxyz"))),FALSE,TRUE))"
.InputTitle = "Integers"
.ErrorTitle = "Integers"
.InputMessage = "Enter an integer from five to ten"
.ErrorMessage = "You must enter a number from five to ten"
End With
End Sub
"inside the string must be doubled."=IF(B3="""",TRUE,IF(ISERROR(SUMPRODUCT(SEARCH(MID(B3,ROW(INDIRECT(""15:""&LEN(B3))),15),""0123456789""&""abcdefghijklmnopqrstuvwxyz""))),FALSE,TRUE))""wouldn't work in a normal cell in excel, this is just how you have to write it when insert a formula via VBA.