I am wondering if there is a way to check the value of a variable against a list within my vba code. Sort of like using data validation, but instead of referencing a range on a worksheet, it would reference a list stored directly in my code. I envision something like:
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
Dim List as integer
Dim ChangingVariable as integer
<o></o>
List = ( any of the numbers 1,2,3,4,5,6,7 or 8) ‘or whatever the code should be
<o></o>
' do some stuff that ends up with ChangingVariable = 3
<o></o>
If ChangingVariable = List then ' i.e. if the number is in the list
' do some stuff
Else
' do some other stuff
End If
<o></o>
If this was SQL I would think of using the IN function, but as far as I can tell that doesn’t work in VBA.
Thanks for the help!
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
Dim List as integer
Dim ChangingVariable as integer
<o></o>
List = ( any of the numbers 1,2,3,4,5,6,7 or 8) ‘or whatever the code should be
<o></o>
' do some stuff that ends up with ChangingVariable = 3
<o></o>
If ChangingVariable = List then ' i.e. if the number is in the list
' do some stuff
Else
' do some other stuff
End If
<o></o>
If this was SQL I would think of using the IN function, but as far as I can tell that doesn’t work in VBA.
Thanks for the help!