Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1664
  • Last Modified:

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
0
RichNH
Asked:
RichNH
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
0
 
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
 
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now