Link to home
Start Free TrialLog in
Avatar of RichNH
RichNH

asked on

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
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RichNH
RichNH

ASKER

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.