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,0 9,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
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,0
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
http://www.techonthenet.com/excel/formulas/match.php
combined with the SPLIT function:
http://visualbasic.about.com/od/learnvb6/l/blvbsplit.htm