I'm back with another question in VBA.
Here's the (updated) file I'm working on. When I try to run it, it says
Run-time error '92': For loop not initialized
.
The loop is For Each var In accepted
and I have already defined var
and accepted
as follows:
Dim accepted() As Variant
Dim var As Variant
...
For Each var In accepted
...
Next var
I'm not sure why this error is occurring.
Best Answer
In VBA you can't use a For Loop on an array with no dimensions defined.
So if your
accepted
array hasn't been (Re)Dim'ed to have an actual dimension before the Loop starts, you'll get that error.Check out this StackOverflow question for some ways to deal with (potentially) non-dimensioned arrays: