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


I know this is an incredibly stupid question, but I've read my VBA book,
sites, and forum, and have not found the answer. All I'm trying to do
is create a simple dropdown box with five words that the user can
select from.

I tried this from what I've found, but it's not working:

Private Sub UserForm_Initialize()
'
'filling the combo box with values
'
With WeatherComboBox
..AddItem = "Sunny"
..AddItem = "Cloudy"
..AddItem = "Foggy"
..AddItem = "Rainy"
..AddItem = "Snowy"
End With
'
'selects the first list item
'
WeatherComboBox.ListIndex = 0
'
End Sub

---

thanks.


--
cliodne
------------------------------------------------------------------------
cliodne's Profile: http://www.excelforum.com/member.php...o&userid=28774
View this thread: http://www.excelforum.com/showthread...hreadid=490616

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default filling a simple combobox

c,
Add a dot in front of all of the AddItems...
.AddItem
Jim Cone
San Francisco, USA
'------------------------------------


"cliodne" wrote in message ...
I know this is an incredibly stupid question, but I've read my VBA book,
sites, and forum, and have not found the answer. All I'm trying to do
is create a simple dropdown box with five words that the user can
select from.
I tried this from what I've found, but it's not working:

Private Sub UserForm_Initialize()'
'filling the combo box with values
'
With WeatherComboBox
AddItem = "Sunny"
AddItem = "Cloudy"
AddItem = "Foggy"
AddItem = "Rainy"
AddItem = "Snowy"
End With
'
'selects the first list item'
WeatherComboBox.ListIndex = 0
'
End Sub
thanks.
cliodne

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default filling a simple combobox


Hey Jim

In my code, I've already added the "."

The the problem because the code is in the UserForm_Initialize? I
tried putting it in the WeatherComboBox_Change, but that didnt' work
either.

Thanks,
Cami


--
cliodne
------------------------------------------------------------------------
cliodne's Profile: http://www.excelforum.com/member.php...o&userid=28774
View this thread: http://www.excelforum.com/showthread...hreadid=490616

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default filling a simple combobox

This worked fine for me (take out the Equal sign)

Private Sub UserForm_Initialize()

'
'filling the combo box with values
'
With WeatherCombobox
.AddItem "Sunny"
.AddItem "Cloudy"
.AddItem "Foggy"
.AddItem "Rainy"
.AddItem "Snowy"
End With
'
'selects the first list item
'
WeatherCombobox.ListIndex = 0
'
End Sub

--
Regards,
Tom Ogilvy


"cliodne" wrote in
message ...

Hey Jim

In my code, I've already added the "."

The the problem because the code is in the UserForm_Initialize? I
tried putting it in the WeatherComboBox_Change, but that didnt' work
either.

Thanks,
Cami


--
cliodne
------------------------------------------------------------------------
cliodne's Profile:

http://www.excelforum.com/member.php...o&userid=28774
View this thread: http://www.excelforum.com/showthread...hreadid=490616



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default filling a simple combobox

Get rid of the equal sign's

.additem "Sunny"

And make sure you don't have a .rowsource assigned to that combobox.

Option Explicit
Private Sub UserForm_Initialize()
'
'filling the combo box with values
'
With WeatherComboBox
.RowSource = ""
.AddItem "Sunny"
.AddItem "Cloudy"
.AddItem "Foggy"
.AddItem "Rainy"
.AddItem "Snowy"
End With
'
'selects the first list item
'
WeatherComboBox.ListIndex = 0
'

End Sub

cliodne wrote:

I know this is an incredibly stupid question, but I've read my VBA book,
sites, and forum, and have not found the answer. All I'm trying to do
is create a simple dropdown box with five words that the user can
select from.

I tried this from what I've found, but it's not working:

Private Sub UserForm_Initialize()
'
'filling the combo box with values
'
With WeatherComboBox
AddItem = "Sunny"
AddItem = "Cloudy"
AddItem = "Foggy"
AddItem = "Rainy"
AddItem = "Snowy"
End With
'
'selects the first list item
'
WeatherComboBox.ListIndex = 0
'
End Sub

---

thanks.

--
cliodne
------------------------------------------------------------------------
cliodne's Profile: http://www.excelforum.com/member.php...o&userid=28774
View this thread: http://www.excelforum.com/showthread...hreadid=490616


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default filling a simple combobox


Thank you everyone!

It's much appreicated,
Cami


--
cliodne
------------------------------------------------------------------------
cliodne's Profile: http://www.excelforum.com/member.php...o&userid=28774
View this thread: http://www.excelforum.com/showthread...hreadid=490616

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
Filling combobox with variable length list Denny Behnfeldt Excel Programming 3 January 2nd 05 06:31 PM
Filling form text boxes from cells. Incredibly simple I know, but I'm new. :-( Paul Crabb Excel Programming 0 November 18th 04 01:49 AM
searching for a combobox.value and filling in textboxes from results GregJG[_18_] Excel Programming 3 July 8th 04 12:41 PM
Filling a ComboBox? CG Rosén Excel Programming 1 July 1st 04 02:33 AM
filling a combobox (without being prompted to save the workbook EVERY time its opened neowok[_34_] Excel Programming 2 March 1st 04 03:39 PM


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