Making empty a VBA collection Making empty a VBA collection vba vba

Making empty a VBA collection


If you want to empty a collection, instead of calling a separate procedure, just use

Set listado = New Collection


Dim listado As New Collection<I have some code here that add some values to the collection>limpieza listado'this syntax also worksCall limpieza(listado)

Note that I removed the () around the argument.

When passing byref you want to do this as () causes VBA to pass it as byval by default unless you add Call as well.

This can be really frustrating since you can often actually use subName(args) as syntax sometimes but run into these sorts of problems. I generally use Call mySubName(args) to make things more clear.