ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Removing item from combobox with vba (https://www.excelbanter.com/excel-programming/311306-removing-item-combobox-vba.html)

SOS[_34_]

Removing item from combobox with vba
 

Hi all,

I am working on a soccer form and currently have 2 comboboxes (alon
with other controls) on a userform named comTeam1 and comTeam2 . The
are both populated with the same list of teams as the workbook opens.

Since a team cannot play against itself I would like to remove the tea
chosen in comTeam1 from comTeam2 when comTeam1 is changed.

I have tried:

Private Sub comTeam1_Change()
comTeam2.RemoveItem comTeam1.Value
End Sub

but this gives me an invalid call error. I would be grateful for som
help in this direction.

Many thanks

Seamu

--
SO
-----------------------------------------------------------------------
SOS's Profile: http://www.excelforum.com/member.php...nfo&userid=540
View this thread: http://www.excelforum.com/showthread.php?threadid=26314


Tom Ogilvy

Removing item from combobox with vba
 
How do you populate the comboboxes. If you bind the data to the control
(using the listfillrange or rowsource property), then you won't be able to
use removeitem.

--
Regards,
Tom Ogilvy

"SOS" wrote in message
...

Hi all,

I am working on a soccer form and currently have 2 comboboxes (along
with other controls) on a userform named comTeam1 and comTeam2 . They
are both populated with the same list of teams as the workbook opens.

Since a team cannot play against itself I would like to remove the team
chosen in comTeam1 from comTeam2 when comTeam1 is changed.

I have tried:

Private Sub comTeam1_Change()
comTeam2.RemoveItem comTeam1.Value
End Sub

but this gives me an invalid call error. I would be grateful for some
help in this direction.

Many thanks

Seamus


--
SOS
------------------------------------------------------------------------
SOS's Profile:

http://www.excelforum.com/member.php...fo&userid=5406
View this thread: http://www.excelforum.com/showthread...hreadid=263147





All times are GMT +1. The time now is 09:12 AM.

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