Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I know this is simple, but I just can't remember the syntax. How do I clear
all the items from a combo box? Isn't there a one-step process for doing this? All help appreciated. TIA. -gk- |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use the Clear method of the ComboBox control. E.g.,
Userform1.ComboBox1.Clear -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "39N95W" wrote in message ... I know this is simple, but I just can't remember the syntax. How do I clear all the items from a combo box? Isn't there a one-step process for doing this? All help appreciated. TIA. -gk- |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If bound to a worksheet using rowsource for example, just set the rowsource
to a null string. If added using additem, then use removeitem. or Private Sub CommandButton2_Click() Dim Emp() ReDim Emp(0 To 0) Me.ComboBox1.List = Emp Me.ComboBox1.RemoveItem 0 End Sub -- Regards, Tom Ogilvy "39N95W" wrote in message ... I know this is simple, but I just can't remember the syntax. How do I clear all the items from a combo box? Isn't there a one-step process for doing this? All help appreciated. TIA. -gk- |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Whoops -
As Chip said, clear would be a better approach for controls not bound to the spread sheet. -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... If bound to a worksheet using rowsource for example, just set the rowsource to a null string. If added using additem, then use removeitem. or Private Sub CommandButton2_Click() Dim Emp() ReDim Emp(0 To 0) Me.ComboBox1.List = Emp Me.ComboBox1.RemoveItem 0 End Sub -- Regards, Tom Ogilvy "39N95W" wrote in message ... I know this is simple, but I just can't remember the syntax. How do I clear all the items from a combo box? Isn't there a one-step process for doing this? All help appreciated. TIA. -gk- |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am having a similar problem. But what if you have a '.change'
routine that should perform the .clear function? The .clear seems to fire the .change and you get .clear twice without re-loading the combobox, and you get a crash. What is the best way to work around this? "Chip Pearson" wrote in message ... Use the Clear method of the ComboBox control. E.g., Userform1.ComboBox1.Clear -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "39N95W" wrote in message ... I know this is simple, but I just can't remember the syntax. How do I clear all the items from a combo box? Isn't there a one-step process for doing this? All help appreciated. TIA. -gk- |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The easiest way to do this, I think, is with a global variable. For
example, you could do something like this: Dim stopEvents as boolean Private Sub object1_change() stopEvents = true do the clear stopEvents = false end sub Private Sub object2_change() if not(stopEvents) then do something end if end sub Stan Scott New York City "Tim Coddington" wrote in message ... I am having a similar problem. But what if you have a '.change' routine that should perform the .clear function? The .clear seems to fire the .change and you get .clear twice without re-loading the combobox, and you get a crash. What is the best way to work around this? "Chip Pearson" wrote in message ... Use the Clear method of the ComboBox control. E.g., Userform1.ComboBox1.Clear -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "39N95W" wrote in message ... I know this is simple, but I just can't remember the syntax. How do I clear all the items from a combo box? Isn't there a one-step process for doing this? All help appreciated. TIA. -gk- |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, Stan. I suppose I could just look at .listindex.
"Stan Scott" wrote in message ... The easiest way to do this, I think, is with a global variable. For example, you could do something like this: Dim stopEvents as boolean Private Sub object1_change() stopEvents = true do the clear stopEvents = false end sub Private Sub object2_change() if not(stopEvents) then do something end if end sub Stan Scott New York City "Tim Coddington" wrote in message ... I am having a similar problem. But what if you have a '.change' routine that should perform the .clear function? The .clear seems to fire the .change and you get .clear twice without re-loading the combobox, and you get a crash. What is the best way to work around this? "Chip Pearson" wrote in message ... Use the Clear method of the ComboBox control. E.g., Userform1.ComboBox1.Clear -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "39N95W" wrote in message ... I know this is simple, but I just can't remember the syntax. How do I clear all the items from a combo box? Isn't there a one-step process for doing this? All help appreciated. TIA. -gk- |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "Chip Pearson" wrote in message ... Use the Clear method of the ComboBox control. E.g., Userform1.ComboBox1.Clear Doh! Let me just say that, swear on my daddy's grave, that I tried typing in the form object, pressing "." after the combobox and then scrolling through the list of options. For what ever reason, I just wasn't seeing it. Thanks again! -gk- |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
nope.
For a combobox and listbox (UNBOUND) setting the list to an empty array is faster than using the clear method. with 100'000 items takes 2.2secs vs 0.06 sec keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool "Tom Ogilvy" wrote: Whoops - As Chip said, clear would be a better approach for controls not bound to the spread sheet. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to clear a group of combo boxes after a submit to another worksheet | Excel Discussion (Misc queries) | |||
Clear a set of combo boxes after a Submit of data to a new sheet. | Excel Worksheet Functions | |||
Clear entries on Combo box | Excel Discussion (Misc queries) | |||
clear form combo boxes problem | Excel Programming | |||
Combo Box Item | Excel Programming |