![]() |
Fill a ListBox with items using VBA
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??? |
Fill a ListBox with items using VBA
You need to qualify the control name with the sheet name; e.g.:
Sheet1.ListBox_1 -- Vasant wrote in message om... 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??? |
All times are GMT +1. The time now is 02:59 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com