Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default 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
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
User created function not "updating" Richard Edwards Excel Worksheet Functions 3 November 30th 07 09:31 AM
Listbox header inside VBA (Array("Head1", "Head2", ...) Alex St-Pierre Excel Programming 2 October 25th 06 09:28 PM
Showing "Created by User, Date, Time" in Footer Mark Plaideau Excel Discussion (Misc queries) 0 April 9th 06 11:29 PM
Disable Close "X" button on User Forms Celtic_Avenger[_50_] Excel Programming 0 October 11th 04 06:25 PM
Disable Close "X" button on User Forms Celtic_Avenger[_49_] Excel Programming 2 October 11th 04 06:20 PM


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