Wasn't there an INLIST function at one time?

For some reason I seem to remember some function that allowed you to test if a string was in a list of specific values.  I'm working in Excel 2007 VBA...

My code looks like this

If Mid(txtSN, 4, 2) <> "01" And Mid(txtSN, 4, 2) <> "02" And Mid(txtSN, 4, 2) <> "03" And Mid(txtSN, 4, 2) <> "04" And Mid(txtSN, 4, 2) <> "05" And Mid(txtSN, 4, 2) <> "06" And Mid(txtSN, 4, 2) <> "07" And Mid(txtSN, 4, 2) <> "08" And Mid(txtSN, 4, 2) <> "09" And Mid(txtSN, 4, 2) <> "10" And Mid(txtSN, 4, 2) <> "11" And Mid(txtSN, 4, 2) <> "12" Then
            MsgBox "Serial # not in correct format, digits in positions 5-6 should be 01-12, YY-0MM-###"

And I wanted to write sometime like this
If INLIST(mid(txtSN,4,2), "01,02,03,04,05,06,07,08,09,10,11,12" then  blah

But obviously that won't compute.

Anyone remember and how would I write it?  I'm not looking for custom code, just a canned function.

Rich
LVL 1
RichNHAsked:
Who is Participating?
 
Patrick MatthewsCommented:
Hello RichNH,

Another alternative...

If InStr(1, "," & Mid(txtSN, 4, 2) & ",", ",01,02,03,04,05,06,07,08,09,10,11,12,") > 0 Then ...

Regards,

Patrick
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
0
 
RichNHAuthor Commented:
That was what I was looking for, only thing is that the parms were backwards,  The larger string needs to be first and the sub string needs to be second.  Other than that, it works like a charm.  Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.