Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default Form Help - ComboBox - VBA

I have a form and when I initialize the form I need multiple combo
boxes to fill in with the same data. Is there an easier way then
doing .additem for each one? My code below.

Thanks Jay

Private Sub UserForm_Initialize()


With CmbxFirst 'this loads the combo
.AddItem "LDC"
.AddItem "DC"
.AddItem "DB"
.AddItem "LDDB"
.AddItem "XmasDB"
.AddItem "XmasLDDB"
.AddItem "XmasDC"
.AddItem "XmasLDC"
.AddItem "No Die"
.AddItem "Same Die As"
End With
With CmbxSecond 'this loads the combo
.AddItem "LDC"
.AddItem "DC"
.AddItem "DB"
.AddItem "LDDB"
.AddItem "XmasDB"
.AddItem "XmasLDDB"
.AddItem "XmasDC"
.AddItem "XmasLDC"
.AddItem "No Die"
.AddItem "Same Die As"
End With
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,549
Default Form Help - ComboBox - VBA


Private Sub UserForm_Initialize()
Dim varList As Variant
varList = Array("LDC", "DC", "DB", "LDDB", "XmasDB", "XmasLDDB", _
"XmasDC", "XmasLDC", "No Die", "Same Die As")
CmbxFirst.List = varList
CmbxSecond.List = varList
End Sub
--
Jim Cone
Portland, Oregon USA


"jlclyde"

wrote in message
I have a form and when I initialize the form I need multiple combo
boxes to fill in with the same data. Is there an easier way then
doing .additem for each one? My code below.
Thanks Jay

Private Sub UserForm_Initialize()
With CmbxFirst 'this loads the combo
.AddItem "LDC"
.AddItem "DC"
.AddItem "DB"
.AddItem "LDDB"
.AddItem "XmasDB"
.AddItem "XmasLDDB"
.AddItem "XmasDC"
.AddItem "XmasLDC"
.AddItem "No Die"
.AddItem "Same Die As"
End With
With CmbxSecond 'this loads the combo
.AddItem "LDC"
.AddItem "DC"
.AddItem "DB"
.AddItem "LDDB"
.AddItem "XmasDB"
.AddItem "XmasLDDB"
.AddItem "XmasDC"
.AddItem "XmasLDC"
.AddItem "No Die"
.AddItem "Same Die As"
End With
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default Form Help - ComboBox - VBA

On Jan 13, 1:11*pm, "Jim Cone" wrote:
Private Sub UserForm_Initialize()
* Dim varList As Variant
* varList = Array("LDC", "DC", "DB", "LDDB", "XmasDB", "XmasLDDB", _
* * * * * * * * * * * * * * "XmasDC", "XmasLDC", "No Die", "Same Die As")
* CmbxFirst.List = varList
* CmbxSecond.List = varList
End Sub
--
Jim Cone
Portland, Oregon *USA

"jlclyde"

wrote in message
I have a form and when I initialize the form I need multiple combo
boxes to fill in with the same data. *Is there an easier way then
doing .additem for each one? *My code below.
Thanks Jay

Private Sub UserForm_Initialize()
With CmbxFirst 'this loads the combo
* * .AddItem "LDC"
* * .AddItem "DC"
* * .AddItem "DB"
* * .AddItem "LDDB"
* * .AddItem "XmasDB"
* * .AddItem "XmasLDDB"
* * .AddItem "XmasDC"
* * .AddItem "XmasLDC"
* * .AddItem "No Die"
* * .AddItem "Same Die As"
End With
With CmbxSecond 'this loads the combo
* * .AddItem "LDC"
* * .AddItem "DC"
* * .AddItem "DB"
* * .AddItem "LDDB"
* * .AddItem "XmasDB"
* * .AddItem "XmasLDDB"
* * .AddItem "XmasDC"
* * .AddItem "XmasLDC"
* * .AddItem "No Die"
* * .AddItem "Same Die As"
End With


Jim,
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default Form Help - ComboBox - VBA

On Jan 13, 1:11*pm, "Jim Cone" wrote:
Private Sub UserForm_Initialize()
* Dim varList As Variant
* varList = Array("LDC", "DC", "DB", "LDDB", "XmasDB", "XmasLDDB", _
* * * * * * * * * * * * * * "XmasDC", "XmasLDC", "No Die", "Same Die As")
* CmbxFirst.List = varList
* CmbxSecond.List = varList
End Sub
--
Jim Cone
Portland, Oregon *USA

"jlclyde"

wrote in message
I have a form and when I initialize the form I need multiple combo
boxes to fill in with the same data. *Is there an easier way then
doing .additem for each one? *My code below.
Thanks Jay

Private Sub UserForm_Initialize()
With CmbxFirst 'this loads the combo
* * .AddItem "LDC"
* * .AddItem "DC"
* * .AddItem "DB"
* * .AddItem "LDDB"
* * .AddItem "XmasDB"
* * .AddItem "XmasLDDB"
* * .AddItem "XmasDC"
* * .AddItem "XmasLDC"
* * .AddItem "No Die"
* * .AddItem "Same Die As"
End With
With CmbxSecond 'this loads the combo
* * .AddItem "LDC"
* * .AddItem "DC"
* * .AddItem "DB"
* * .AddItem "LDDB"
* * .AddItem "XmasDB"
* * .AddItem "XmasLDDB"
* * .AddItem "XmasDC"
* * .AddItem "XmasLDC"
* * .AddItem "No Die"
* * .AddItem "Same Die As"
End With


Jim,
You are a genious. This works awesome. thanks for the help.
Jay
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,549
Default Form Help - ComboBox - VBA

You are welcome.
--
Jim Cone
Portland, Oregon USA



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Form Help - ComboBox - VBA

Hi,

To make the list easily maintainable I'd store them on a worksheet (in this
case sheet4) and load them like this

Private Sub UserForm_Activate()
Dim rng As Range
Dim arr As Variant
Set SH = Sheets("Sheet4")
Set rng = SH.Range("A1:A10")
arr = rng.Value
Me.CmbxFirst.List = arr
End Sub

Mike

"jlclyde" wrote:

I have a form and when I initialize the form I need multiple combo
boxes to fill in with the same data. Is there an easier way then
doing .additem for each one? My code below.

Thanks Jay

Private Sub UserForm_Initialize()


With CmbxFirst 'this loads the combo
.AddItem "LDC"
.AddItem "DC"
.AddItem "DB"
.AddItem "LDDB"
.AddItem "XmasDB"
.AddItem "XmasLDDB"
.AddItem "XmasDC"
.AddItem "XmasLDC"
.AddItem "No Die"
.AddItem "Same Die As"
End With
With CmbxSecond 'this loads the combo
.AddItem "LDC"
.AddItem "DC"
.AddItem "DB"
.AddItem "LDDB"
.AddItem "XmasDB"
.AddItem "XmasLDDB"
.AddItem "XmasDC"
.AddItem "XmasLDC"
.AddItem "No Die"
.AddItem "Same Die As"
End With

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
fill combobox depending on selection from another combobox Adam Francis Excel Discussion (Misc queries) 2 July 24th 08 07:39 PM
Using a template form, advance a form number everytime you open ShoDan Excel Discussion (Misc queries) 1 January 31st 08 01:34 PM
Disable and enable dropdown combobox(Form Control) Vinod[_2_] Excel Discussion (Misc queries) 0 November 6th 07 07:30 PM
link form combobox hngo Excel Worksheet Functions 0 July 28th 06 03:38 PM
VBA Form ComboBox question WTG Excel Worksheet Functions 3 February 26th 05 04:27 PM


All times are GMT +1. The time now is 01:37 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"