budekatude
budekatude

Reputation: 443

AddItem method after RowSource property has previously been set

I have a ComboBox (Combo) on a UserForm (UF) which is populated using the RowSource property.

However, lateron in the programm I need to empty the ComboBox and populate it using the AddItem method, which is not working because access is denied. Apparently this is due to the fact that it's RowSource has been set previously:

UF.Combo.RowSource = Worksheets(WorksheetName).Cells(1,2)    

UF.Combo.AddItem Worksheets(WorksheetName).Cells(2,2)

Is there any way to reset the RowSource property in order to make the ComboBox accessible with AddItem again?

Thanks for your help in advance!

Upvotes: 2

Views: 944

Answers (1)

budekatude
budekatude

Reputation: 443

I just stumbled across the solution by chance...

I tried to set the RowSource property to Nothing (in order to reset it), but it turns out an empty String does the trick:

UF.Combo.RowSource = ""

And the ComboBox can afterwards again be populated using AddItem method as stated in the original question.

Upvotes: 1

Related Questions