ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clear button adds to combo box lists (https://www.excelbanter.com/excel-programming/370651-clear-button-adds-combo-box-lists.html)

alann2

Clear button adds to combo box lists
 

Hi all,
when I press the clear button on my user form it repopulates the
combo box list when I press the clear button.

For instance when I operate

Private Sub cmdClearForm_Click()

Call UserForm_Initialize

End Sub

It adds the same information again to my drop down lists. i.e I have 5
names, when I press the clear button once, I get ten names, this is
repaeted ad infinitum.

What am I doing wrong?

excel 2003 all updated on WinXP PRO

Thank you all.

ALan.


--
alann2
------------------------------------------------------------------------
alann2's Profile: http://www.excelforum.com/member.php...o&userid=37531
View this thread: http://www.excelforum.com/showthread...hreadid=572580


Tom Ogilvy

Clear button adds to combo box lists
 
It sounds like you are using Additem. If so, you need to remove the existing
entires first.


Combobox1.Clear
for i = 1 to 5
Combobox1.AddItem "Item " & i
Next

as an example.

--
Regards,
Tom Ogilvy



"alann2" wrote:


Hi all,
when I press the clear button on my user form it repopulates the
combo box list when I press the clear button.

For instance when I operate

Private Sub cmdClearForm_Click()

Call UserForm_Initialize

End Sub

It adds the same information again to my drop down lists. i.e I have 5
names, when I press the clear button once, I get ten names, this is
repaeted ad infinitum.

What am I doing wrong?

excel 2003 all updated on WinXP PRO

Thank you all.

ALan.


--
alann2
------------------------------------------------------------------------
alann2's Profile: http://www.excelforum.com/member.php...o&userid=37531
View this thread: http://www.excelforum.com/showthread...hreadid=572580



drawlings[_11_]

Clear button adds to combo box lists
 

The code that fills the list box add this to the top

list1.clear

This way it will clear it each time the code is calle

--
drawling
-----------------------------------------------------------------------
drawlings's Profile: http://www.excelforum.com/member.php...fo&userid=3662
View this thread: http://www.excelforum.com/showthread.php?threadid=57258


alann2[_2_]

Clear button adds to combo box lists
 

That was just what I needed.
No doubt I'll be calling on youor services again.
I only started Trying to Program Yesterday morning.

Alan.


--
alann2
------------------------------------------------------------------------
alann2's Profile: http://www.excelforum.com/member.php...o&userid=37531
View this thread: http://www.excelforum.com/showthread...hreadid=572580



All times are GMT +1. The time now is 03:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com