#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default combo boxes

Hi,

I created a few comboboxes in my ms excel 2000 spreadsheet
and filled them using the VBA commands like:

ComboBox3.List = Array("No", "Yes")

When I later re-open the spreadsheet, the comboboxes are
empty! I have to recompile the code to see the items in
the comboboxes.

Does anyone know why this is happening and how to fix it!?

Thanks :)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default combo boxes

The combobox has to know somehow that it has those list items, so mayb
you could place the pice of code in the workbook's open event, o
another way is to have the elements in a range and link this range t
the combo-box

- Manges

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 231
Default combo boxes

hi,

I'm not sure I understand what you mean?? Sorry I haven't
used excel much!

What's the workbook's open event??

Thanks! :)
-----Original Message-----
The combobox has to know somehow that it has those list

items, so maybe
you could place the pice of code in the workbook's open

event, or
another way is to have the elements in a range and link

this range to
the combo-box

- Mangesh


---
Message posted from http://www.ExcelForum.com/

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default combo boxes

ok. In that case, do the following. As you said earlier, you have th
vba command ComboBox3.List = Array("No", "Yes"). Name the sub in whic
this line is as:

Sub Auto_Open()

This would be enough.

- Manges

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default combo boxes

Hey Mangesh,

So the VBA code I changed it to:

Sub Auto_Open()
'... more stuff here

ComboBox3.List = Array("No", "Yes")

'... more stuff here
End Sub

But when I reopen the spreadsheet, the comboboxes are
still empty?!

I entered in the data on another sheet and I used the
range (sheet2!a1:a2)... to hold the data. but that
combobox is not in the location I want on the spreadsheet,
its just a separate userform. :S

Help please! :D


-----Original Message-----
ok. In that case, do the following. As you said earlier,

you have the
vba command ComboBox3.List = Array("No", "Yes"). Name the

sub in which
this line is as:

Sub Auto_Open()

This would be enough.

- Mangesh


---
Message posted from http://www.ExcelForum.com/

.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default combo boxes

Workbook_Open is a special procedure that executes when the workbook is
opened (unless the user disables macros or security settings disable
macros).

You can read about events he

http://www.cpearson.com/excel/events.htm
Chip Pearson's page on events. These events were introduced in xl97 and are
the preferred events. Prior to xl97, there were events such as Auto_Open,
Auto_Close and so forth. These are still supported. These older style
events go in regular or standard modules, while the newer events go in the
special modules ThisWorkbook (for workbook level events) or the related
Sheet module if sheet level events.

As for comboboxes, if you populate them with code (using additem as an
example), then the populated list lasts only as long as the workbook is
open. When closed, the items in the list are lost and must be repopulated.
This is why it was suggested you do this in the workbook_open or the older
equivalent Auto_open events.

--
Regards,
Tom Ogilvy

"sarah" wrote in message
...
hi,

I'm not sure I understand what you mean?? Sorry I haven't
used excel much!

What's the workbook's open event??

Thanks! :)
-----Original Message-----
The combobox has to know somehow that it has those list

items, so maybe
you could place the pice of code in the workbook's open

event, or
another way is to have the elements in a range and link

this range to
the combo-box

- Mangesh


---
Message posted from http://www.ExcelForum.com/

.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 231
Default combo boxes

Hey Tom,

Thanks for the info. :)

But I'm still not quite understanding how to do this? I
just rename the Sub to Auto_Open/Workbook_Open ?? cuz that
doesn't seem to be working :S

Sorry I'm new to all this!

-----Original Message-----
Workbook_Open is a special procedure that executes when

the workbook is
opened (unless the user disables macros or security

settings disable
macros).

You can read about events he

http://www.cpearson.com/excel/events.htm
Chip Pearson's page on events. These events were

introduced in xl97 and are
the preferred events. Prior to xl97, there were events

such as Auto_Open,
Auto_Close and so forth. These are still supported.

These older style
events go in regular or standard modules, while the newer

events go in the
special modules ThisWorkbook (for workbook level events)

or the related
Sheet module if sheet level events.

As for comboboxes, if you populate them with code (using

additem as an
example), then the populated list lasts only as long as

the workbook is
open. When closed, the items in the list are lost and

must be repopulated.
This is why it was suggested you do this in the

workbook_open or the older
equivalent Auto_open events.

--
Regards,
Tom Ogilvy

"sarah" wrote in message
...
hi,

I'm not sure I understand what you mean?? Sorry I

haven't
used excel much!

What's the workbook's open event??

Thanks! :)
-----Original Message-----
The combobox has to know somehow that it has those list

items, so maybe
you could place the pice of code in the workbook's open

event, or
another way is to have the elements in a range and link

this range to
the combo-box

- Mangesh


---
Message posted from http://www.ExcelForum.com/

.



.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 231
Default combo boxes

Hey!

Nevermind I figured it out! Yaaay!... I had the code in
the 'Sheet1 module' and it should've been in the
ThisWorkbook module.... thanks!

-----Original Message-----
Hey Tom,

Thanks for the info. :)

But I'm still not quite understanding how to do this? I
just rename the Sub to Auto_Open/Workbook_Open ?? cuz

that
doesn't seem to be working :S

Sorry I'm new to all this!

-----Original Message-----
Workbook_Open is a special procedure that executes when

the workbook is
opened (unless the user disables macros or security

settings disable
macros).

You can read about events he

http://www.cpearson.com/excel/events.htm
Chip Pearson's page on events. These events were

introduced in xl97 and are
the preferred events. Prior to xl97, there were events

such as Auto_Open,
Auto_Close and so forth. These are still supported.

These older style
events go in regular or standard modules, while the

newer
events go in the
special modules ThisWorkbook (for workbook level events)

or the related
Sheet module if sheet level events.

As for comboboxes, if you populate them with code (using

additem as an
example), then the populated list lasts only as long as

the workbook is
open. When closed, the items in the list are lost and

must be repopulated.
This is why it was suggested you do this in the

workbook_open or the older
equivalent Auto_open events.

--
Regards,
Tom Ogilvy

"sarah" wrote in

message
...
hi,

I'm not sure I understand what you mean?? Sorry I

haven't
used excel much!

What's the workbook's open event??

Thanks! :)
-----Original Message-----
The combobox has to know somehow that it has those

list
items, so maybe
you could place the pice of code in the workbook's

open
event, or
another way is to have the elements in a range and

link
this range to
the combo-box

- Mangesh


---
Message posted from http://www.ExcelForum.com/

.



.

.

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
Getting Combo boxes to change options based on other Combo boxes. Ancient Wolf New Users to Excel 1 March 27th 09 06:29 PM
Selecting subsets using combo boxes or list boxes CLamar Excel Discussion (Misc queries) 0 June 1st 06 07:43 PM
Questions on combo boxes and list boxes. Marc New Users to Excel 1 March 14th 06 09:40 AM
Combo Boxes Christine Excel Discussion (Misc queries) 1 March 29th 05 08:08 PM
List boxes/combo boxes Tibow Excel Programming 3 February 17th 04 12:35 PM


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