Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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???
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default 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???



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort Listbox Items Stratuser Excel Programming 2 January 17th 04 03:05 PM
Listbox--moving items up or down libby Excel Programming 0 November 7th 03 06:53 PM
listing items from listbox Gerry[_5_] Excel Programming 2 October 18th 03 02:45 AM
Counting items in a listbox Thurman Excel Programming 0 September 5th 03 06:36 AM
Checking Listbox Items Tim[_15_] Excel Programming 1 July 20th 03 05:27 PM


All times are GMT +1. The time now is 09:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"