Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

No, items should not be removed from a dictionary while iterating through it using a for-each loop in VBA as it can cause the loop to skip or miss elements, or even throw an error. It is recommended to create a new collection of the items to remove and then remove them outside of the loop. Alternatively, you can loop through the values in reverse order and delete the items as necessary.