Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Combox box question

Hi,
Is there a way to populate more than one combobox with the same information
apart from just repeating the code?

At the moment I'm using the additem function.

Many thanks
David


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Combox box question

it's clumsy but your add item loop could include all your
combos

for each item in mylist
.additem item.value
sheet1.combo1.additem item.value
userform2.combo3.additem item.value
next


another way would be to set the combo's source from a
named range

In the following demo I have an ActiveX Combo on one
sheet, and ActiveX Listbox on another sheet and a
combobox on a userfom

The code below is on a standard module...the procedure
Initialise fetches data from a "database", pushes it into
a column that gets range named, then assigns the name to
the source of the three objects. on your active sheet,
range name one cell as "MyList" to begin with.

Option Explicit

Public Sub inititialise()
Dim col As New Collection
Dim item
Dim index As Long
Dim rTarget As Range
Set rTarget = Sheet2.Range("MyList")
With rTarget
.Clear
.Resize(1, 1).Name = "MyList"
End With
Set rTarget = Sheet2.Range("MyList")
Set col = GetFromDatabase
For Each item In col
rTarget.Offset(index, 0).Value = item
index = index + 1
Next
rTarget.Resize(index, 1).Name = "MyList"

Sheet1.ComboBox1.ListFillRange = "MyList"
Sheet2.ListBox1.ListFillRange = "MyList"
UserForm1.ComboBox1.RowSource = "MyList"

UserForm1.Show vbModeless

End Sub

Private Function GetFromDatabase() As Collection
Dim c As New Collection
With c
.Add "Mike"
.Add "Patrick"
.Add "Ivan"
.Add "Fola"
.Add "Nit"
End With
Set GetFromDatabase = c
Set c = Nothing
End Function


Hpe this demo gives you some ideas

Patrick Molloy
Microsoft Excel MVP



-----Original Message-----
Hi,
Is there a way to populate more than one combobox with

the same information
apart from just repeating the code?

At the moment I'm using the additem function.

Many thanks
David


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Combox box question

Yes, set-up the information in a worksheet and use the ListFillRange
property (RowSource if a userform) to point at that range.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"David Goodall" wrote in message
...
Hi,
Is there a way to populate more than one combobox with the same

information
apart from just repeating the code?

At the moment I'm using the additem function.

Many thanks
David




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
Display data in a combox box Oggy Excel Discussion (Misc queries) 1 January 2nd 07 09:30 PM
Assigning a value to a cell from a combox sjayar Excel Discussion (Misc queries) 3 November 2nd 05 12:58 PM
Combox Locking D.Parker Excel Discussion (Misc queries) 2 April 27th 05 11:03 PM
Combox/Print issue Michael Tearse Excel Programming 1 March 1st 04 02:21 PM
continued combox frustration scrabtree[_2_] Excel Programming 1 October 23rd 03 08:28 AM


All times are GMT +1. The time now is 02:01 AM.

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"