hmm... try this out (see attached to run the macro and step through to see what's it's doing:
Needed a little more code to do this...found a way to loop and repeat the query until the input is OK
Enjoy and rate please
![]()
Option Explicit Sub testcontrol() Dim TestInput As String Dim isOK As Boolean Dim i As Integer, passes As Integer isOK = False passes = 0 Do If passes > 0 Then 'prompt again MsgBox ("please only enter upper-case letters and number at next prompt") TestInput = InputBox("UpperCase Letters & Number only please") Else TestInput = InputBox("UpperCase Letters & Number only please") End If passes = passes + 1 For i = 1 To Len(TestInput) isOK = checkValidity(Mid(TestInput, i, 1)) If isOK = False Then 'bounce i = Len(TestInput) End If Next i Loop While Not isOK End Sub Function checkValidity(test As String) As Boolean Dim i As Integer Dim ok As Boolean Dim valarray(1 To 36) As String ok = False valarray(1) = "A" valarray(2) = "B" valarray(3) = "C" valarray(4) = "D" valarray(5) = "E" valarray(6) = "F" valarray(7) = "G" valarray(8) = "H" valarray(9) = "I" valarray(10) = "J" valarray(11) = "K" valarray(12) = "L" valarray(13) = "M" valarray(14) = "N" valarray(15) = "O" valarray(16) = "P" valarray(17) = "S" valarray(18) = "T" valarray(19) = "W" valarray(20) = "X" valarray(21) = "Y" valarray(22) = "Z" valarray(23) = "0" valarray(24) = "1" valarray(25) = "2" valarray(26) = "3" valarray(27) = "4" valarray(28) = "5" valarray(29) = "6" valarray(30) = "7" valarray(31) = "8" valarray(32) = "9" For i = 1 To 36 If test = valarray(i) Then ok = True End If Next i checkValidity = ok End Function
Bookmarks