Although this is an old thread I thought I should post a solution for the benefit of people Googling this question.
Enums in VBA as in many other languages are just wrappers for Integers, and can be treated as such for a lot of purposes including loops.
So say you have
You can loop over all values with a simple for loop:Code:Enum Weekday Monday Tuesday '.... Saturday Sunday
For day = Monday to Sunday
' Loop code
Next day
Be careful though - if you add a new first or last item to the type such loops will no longer provide complete coverage.
Tested in Excel 2007 but I imagine it will work in all previous versions.




Reply With Quote