Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Empty listbox

I have a listbox on my worksheet and have added some items to it
using:

Sub temp()
With Sheets("Month").ListBox1
.AddItem ("Yesterday")
.AddItem ("Today")
.AddItem ("Tomorrow")
End With
End Sub

That works fine but when I close the sheet and open it again the
entries disappear. I can briefly see them and then the list is empty.
I have removed all ThisWorkbook code and I disable macros when the
spreadsheet opens. But the entries still disappear. What's going on?

TIA,
Derek
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Empty listbox

Derek,

What do you mean by close the sheet? Do you mean you close the workbook
completely? If so, the listbox will not have those values as it will be
re-initialised upon opening the workbook. What you would need to do is put
that code into the Workbook_Open event, so that it is automatically loaded
each time. Either that, or put the values in a worksheet range, and set the
RowSource property to point at that range in the control design.

--

HTH

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

"Derek Gadd" wrote in message
om...
I have a listbox on my worksheet and have added some items to it
using:

Sub temp()
With Sheets("Month").ListBox1
.AddItem ("Yesterday")
.AddItem ("Today")
.AddItem ("Tomorrow")
End With
End Sub

That works fine but when I close the sheet and open it again the
entries disappear. I can briefly see them and then the list is empty.
I have removed all ThisWorkbook code and I disable macros when the
spreadsheet opens. But the entries still disappear. What's going on?

TIA,
Derek



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Empty listbox

Yes, I meant close the workbook completely. If I were to set the
RowSource property, where would the best place be to place the code?
Workbook_open, initialize? Anyway, RowSource wasn't shown in the
properties window but ListFillRange was and I used this with the
values located in the worksheet. That works fine, is it the same
thing? (I'm using Excel 2000.)

Thanks,
Derek

"Bob Phillips" wrote in message ...
Derek,

What do you mean by close the sheet? Do you mean you close the workbook
completely? If so, the listbox will not have those values as it will be
re-initialised upon opening the workbook. What you would need to do is put
that code into the Workbook_Open event, so that it is automatically loaded
each time. Either that, or put the values in a worksheet range, and set the
RowSource property to point at that range in the control design.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Empty listbox

In the Workbook_Open event macro. This goes in the ThisWorkbook code
module. If you select from the left-hand drop-down, you can pick Workbook,
and the then the open event macro is created in base form.

ListFillRange is the correct property, I get the names mixed up.

--

HTH

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

"Derek Gadd" wrote in message
om...
Yes, I meant close the workbook completely. If I were to set the
RowSource property, where would the best place be to place the code?
Workbook_open, initialize? Anyway, RowSource wasn't shown in the
properties window but ListFillRange was and I used this with the
values located in the worksheet. That works fine, is it the same
thing? (I'm using Excel 2000.)

Thanks,
Derek

"Bob Phillips" wrote in message

...
Derek,

What do you mean by close the sheet? Do you mean you close the workbook
completely? If so, the listbox will not have those values as it will be
re-initialised upon opening the workbook. What you would need to do is

put
that code into the Workbook_Open event, so that it is automatically

loaded
each time. Either that, or put the values in a worksheet range, and set

the
RowSource property to point at that range in the control design.



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
Listbox 2 takes the value of Listbox 1 Illya Teideman Excel Discussion (Misc queries) 3 April 10th 07 03:20 PM
listbox B conditional of input in Listbox A Kim K Excel Discussion (Misc queries) 1 October 31st 06 08:27 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM
Sorting ListBox results or transposing ListBox values to other cells for sorting Rob[_8_] Excel Programming 1 July 9th 03 04:35 AM


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