Fill a ListBox with items using VBA

H

hotbero

Hi!

I would like to attach a ListBox, and/or a ComboBox to one of my
Sheets, "NOT A USERFORM".
How can I fill this ComboBox or ListBox with Items using VBA??

Sub Help()
Dim X As Single 'X could be > 200
Dim Myarray() As Variant
'I have 1 ListBox named ListBox_1 and
'1 ComboBox named ComboBox_1 in my Sheet

MyArray=Array("AAA","BBB","CCC","DDD","EEE","FFF","GGG","HHH")
FOR X=lbound(MyArray) to Ubound(MyArray)
ListBox_1.AddItem Myarray(X)
ComboBox_1.AddItem Myarray(X)
Next X

End Sub


This does not Work, Any Help???
 
V

Vasant Nanavati

You need to qualify the control name with the sheet name; e.g.:

Sheet1.ListBox_1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top