Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Populate Combo Box Drop Down with Collection Data

Hey guys,

i previously put a post up about optimising a search feature in a piece of
VBA i was writting, but i have decided against this now as it would just take
up too much time. my new idea of getting around this problem is to take all
the values in a column, pick out 1 instance of each (Via a collection) and
then out put that collection to a drop down menu/Combo Box. this is the code
i have so far, i am just unsure about how to get the collection data into the
combo box.

Sub DropDown()

Dim Cell As Range
Dim Rng As Range
Dim ListEntry As Collection

Sheet1.ComboBoxEntry.Clear

Application.ScreenUpdating = False

Set Rng = Sheets("Data").Range("D:D")

On Error Resume Next
For Each Cell In Rng
ListEntry.Add Cell.Value, CStr(Cell.Value)
Next Cell

For Each Item In ListEntry 'I didnt expect this line to work, just added it
to illustrate what i am after.
Sheets("Summary").ComboBoxEntry.AddItem
Next Item

Application.ScreenUpdating = True

End Sub

i have put this piece of code on the "ThisWorkbook" area of the VBA
enviroment, i have had problems with combo boxes in other work books when i
put code in the sheet the box was on.

any help would be very welcome

The Noob
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Populate Combo Box Drop Down with Collection Data

Nevermind, problem solved.

The Noob

"Noob McKnownowt" wrote:

Hey guys,

i previously put a post up about optimising a search feature in a piece of
VBA i was writting, but i have decided against this now as it would just take
up too much time. my new idea of getting around this problem is to take all
the values in a column, pick out 1 instance of each (Via a collection) and
then out put that collection to a drop down menu/Combo Box. this is the code
i have so far, i am just unsure about how to get the collection data into the
combo box.

Sub DropDown()

Dim Cell As Range
Dim Rng As Range
Dim ListEntry As Collection

Sheet1.ComboBoxEntry.Clear

Application.ScreenUpdating = False

Set Rng = Sheets("Data").Range("D:D")

On Error Resume Next
For Each Cell In Rng
ListEntry.Add Cell.Value, CStr(Cell.Value)
Next Cell

For Each Item In ListEntry 'I didnt expect this line to work, just added it
to illustrate what i am after.
Sheets("Summary").ComboBoxEntry.AddItem
Next Item

Application.ScreenUpdating = True

End Sub

i have put this piece of code on the "ThisWorkbook" area of the VBA
enviroment, i have had problems with combo boxes in other work books when i
put code in the sheet the box was on.

any help would be very welcome

The Noob

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
How can I populate a drop down list from Data Validation? Brian Excel Discussion (Misc queries) 1 August 17th 09 05:32 PM
Populate combo box with external data uwe Excel Programming 2 September 13th 08 04:38 AM
Populate Data w/ Multiple Drop-Downs Tiffany Excel Discussion (Misc queries) 1 August 28th 07 07:54 PM
Populate a column of data with a formula using a drop down list nafflerbach Excel Discussion (Misc queries) 1 May 24th 07 12:20 PM
Populate one combo box based on the selection of another combo box Alex Excel Programming 8 April 19th 07 06:40 PM


All times are GMT +1. The time now is 10:41 PM.

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

About Us

"It's about Microsoft Excel"