Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Listbox 2 takes the value of Listbox 1 | Excel Discussion (Misc queries) | |||
listbox B conditional of input in Listbox A | Excel Discussion (Misc queries) | |||
listbox.value not equal to listbox.list(listbox.listindex,0) | Excel Programming | |||
Is refreshing listbox rowsource in listbox click event possible? | Excel Programming | |||
Sorting ListBox results or transposing ListBox values to other cells for sorting | Excel Programming |