Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to clear all item from a combo box?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How to clear all item from a combo box?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to clear all item from a combo box?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to clear all item from a combo box?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default How to clear all item from a combo box?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default How to clear all item from a combo box?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default How to clear all item from a combo box?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to clear all item from a combo box?


"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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default How to clear all item from a combo box?

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
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
How to clear a group of combo boxes after a submit to another worksheet Jonah Excel Discussion (Misc queries) 1 March 7th 08 12:39 AM
Clear a set of combo boxes after a Submit of data to a new sheet. Jonah Excel Worksheet Functions 0 March 3rd 08 12:05 AM
Clear entries on Combo box casey Excel Discussion (Misc queries) 1 December 13th 06 02:37 AM
clear form combo boxes problem Profairy[_7_] Excel Programming 4 June 9th 04 04:56 PM
Combo Box Item alfaboost Excel Programming 7 January 10th 04 06:31 PM


All times are GMT +1. The time now is 07:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"