Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close na "on the fly" created Listbox if ignored by the user?
How could I use vba to close an "on the fly" created Listbox if
ignored by the user.... if I use the Worksheet_SelectionChange event and say.. ActiveSheet.ListBoxes("OfficeList").Delete for example it is fine if the listbox is open but gives and error if not. I have tried to poll for any open Listboxes ( and hences close them ) but can't get the code right or am I on the "wrong road" ...? Cheers |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close na "on the fly" created Listbox if ignored by the user?
Snowfire wrote:
How could I use vba to close an "on the fly" created Listbox if ignored by the user.... if I use the Worksheet_SelectionChange event and say.. ActiveSheet.ListBoxes("OfficeList").Delete for example it is fine if the listbox is open but gives and error if not. I have tried to poll for any open Listboxes ( and hences close them ) but can't get the code right or am I on the "wrong road" ...? Cheers ActiveSheet.ListBoxes("OfficeList") generates error if OfficeList does not exist. so use that fact function GetOfficeListBox as listbox on error goto trapit set GetOfficeListbox = ActiveSheet("officelist") exit function trapit: set GetOfficeListbox = nothing end function in your main program dim olb as listbox set olb = getOfficeListbox () if not olb is nothing then olb.delete end if -------- eventually getOfficeListbox can have a name of listbox as paramater and be used to get listbox reference or nothing for any listbox. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
User created function not "updating" | Excel Worksheet Functions | |||
Listbox header inside VBA (Array("Head1", "Head2", ...) | Excel Programming | |||
Showing "Created by User, Date, Time" in Footer | Excel Discussion (Misc queries) | |||
Disable Close "X" button on User Forms | Excel Programming | |||
Disable Close "X" button on User Forms | Excel Programming |