Hi,
Was wondering as this has come up a few times. What is the most efficient to tell if a value is in a collection. I like SQL for its in statement.
In(1, 2, 3, 4 ,5, 7, 9)
So you can tell if value x is in an array with out having to cycle through the whole array.
Is there any simple function like this in vba?
For example you have a 100 workbooks and you want to cycle through them and copy all their sheets over if they don't already exist there.
I normally end up doing a loop through each workbook then looping through each sheet in the other workbook then setting a boolean and looping through my current workbook sheets collection and any of the sheets names match setting the boolean to true and then based on this copying the sheet and then continuing the other loops. This is a lot of loops and seems innefficient and long winded to type out.
Same goes for if you have 20 values for a combobox and 20 comboboxes and you don't want the values to repeat for each one you need to cycle through all the current values and not allow them.
Hope this is making sense. There are lots of times this situation comes up and there must be a better way of doing it than I have been.