VBA: how to reset an option?

I have the following option:

Dim comboitems() As Variant 

which I use throughout the code as an array containing the values โ€‹โ€‹of the ComboBox control.

At a specific point in the code, I need to clear / empty / null comboitems() . How can i do I have tried all of the following options without any success.

 comboitems = "" comboitems = Null comboitems = Nothing Set comboitems = "" Set comboitems = Null Set comboitems = Nothing comboitems() = "" comboitems() = Null comboitems() = Nothing Set comboitems() = "" Set comboitems() = Null Set comboitems() = Nothing 

The error I am getting is this:

enter image description here

+5
source share
1 answer

For array options, you clear them with the delete command.

 Erase comboitems 

Here's a handy reference guide for working with arrays in vba:

https://excelmacromastery.com/excel-vba-array/

+5
source

Source: https://habr.com/ru/post/1274268/


All Articles