Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Problem setting combobox

I have a userform with multiple comboboxes (combobox1 - combobox40)

I want to fill the combobox, preferably using .additem , so that the user
can't change it. Somehow, I can't set the cboBox variable.

This is what I've tried:

Sub FillAllComboBoxes()
dim cboBox as msforms.combobox
dim frmSettings as userform

frmSettings = SettingsForm ' the name of my userform

With frmSettings
.combobox1.additem = "FirstItem" 'works just fine
set cboBox = .combobox1 ' bugs out here
call FillcomboBox(cboBox)
End with
end sub


Sub FillcomboBox(cboBox as MsForms.combobox)

cboBox.additem = "value1"
cboBox.additem = "value2"

End sub

I can't get passed the
set cboBox = .combobox1
line without it bugging out.

Ideally, I'd like to cycle through the combobox using their numbers. I saw
this posting by Tom Ogilvy, but can't get it to work for a userform that is
not part of an active worksheet.

' this declaration is important
Dim cbx as MsForms.Combobox
.. . .
For i = 400 To myrow - 10 Step -1
With ActiveSheet.OLEObjects("ComboBox" & i)
.name = "ComboBox" & i + 1
set cbx = .Object
cbx.Name = "ComboBox" & i + 1
end with
Next i

--






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem setting combobox


Hi try this modified code, it worked for me for Combobox1 i'm using
Excel 2003 Windows XP.

Regards,
Simon

Sub FillAllComboBoxes()
Dim cboBox As MsForms.ComboBox
With settingsform
..ComboBox1.AddItem "FirstItem"
Set cboBox = .ComboBox1
Call FillcomboBox(cboBox)
End With
End Sub


Sub FillcomboBox(cboBox As MsForms.ComboBox)

cboBox.AddItem "value1"
cboBox.AddItem "value2"

End Sub


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=569126

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
setting ComboBox Control font ts1 Excel Programming 0 September 22nd 05 06:35 PM
Setting properties to combobox Stefan[_6_] Excel Programming 2 September 16th 04 12:21 PM
Setting ComboBox ControlSource in code JimPNicholls Excel Programming 4 August 23rd 04 10:44 AM
Combobox setting Pat Excel Programming 4 April 14th 04 09:48 PM
Setting ComboBox Value Ripan[_5_] Excel Programming 0 March 3rd 04 10:52 PM


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