Here's a little more of an esoteric explanation for those who care.
The syntax for a For is
For variable = expression1 To expression2
It looks like you thought it was necessary to repeat the variable after the To.
The statement you wrote says:
Iterate the variable x starting at the value 1 and ending at the value
x = (allergenlist.Count - 1)
In VBA, the = sign can be an assignment statement and it is also a compare operator that returns a Boolean value. So the expression you wrote there is evaluated and returns FALSE, because x is not equal to that value. But the For statement is looking for an integer there, so it interprets the FALSE as 0. So your For statement is effectively
So it goes through once, then quits.
Bookmarks