Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have a userform which is initialized as for next and add items to listbox1 from worksheets range. Now my problem is; I would like to remove item from listbox1 by combobox1.change event. I want if the combobox1.value is equal to the item in 3rd column of listbox1.Is that possible? If so, how can I write that in a code? PS.Above is the only simple sample which would lead me to solve my problem in my project. Thank you very much for your help. Here is my code below Baha Private Sub UserForm_Initialize() Dim cel As Range ComboBox1.AddItem "DLR" ComboBox1.AddItem "DI" ComboBox1.AddItem "SUP" With ListBox1 For Each cel In Sheets("Sheet1").Range("A1:A100") If cel < "" Then ..AddItem cel.Value ..List(.ListCount - 1, 1) = cel.Offset(0, 1) ..List(.ListCount - 1, 2) = cel.Offset(0, 2) End If Next cel End With End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try...
Option Explicit Private Sub ComboBox1_Change() Dim n& With ListBox1 For n = (.ListCount - 1) To 0 Step -1 If .List(n, 2) = ComboBox1.Text Then .RemoveItem (n) Next 'n End With 'ListBox1 End Sub Private Sub UserForm_Initialize() ComboBox1.List = Array("DLR", "DIS", "SUP") Dim vListData vListData = ActiveSheet.Range("A1:C10") '//edit to suit ListBox1.List = vListData End Sub -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Note that I changed your combobox list for consistency only. You should
change "DIS" to "DI" so it reflects your 'house' terminology. -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sunday, March 24, 2013 1:03:38 AM UTC+8, GS wrote:
Note that I changed your combobox list for consistency only. You should change "DIS" to "DI" so it reflects your 'house' terminology. -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion Hi GS, That worked perfectly fine.Oh you made it so easy now.I love that code. Thank you very much for your help. Baha |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sunday, March 24, 2013 1:03:38 AM UTC+8, GS wrote:
Note that I changed your combobox list for consistency only. You should change "DIS" to "DI" so it reflects your 'house' terminology. -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion Hi GS, That worked perfectly fine.Oh you made it so easy now.I love that code. Thank you very much for your help. Baha You're welcome! Always glad to help where/when I can. The feedback is appreciated... -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Add Item To ComboBox List | Excel Programming | |||
ComboBox Will Not Advance To next Item in list | Excel Programming | |||
Combobox item selection+pop up list | Excel Programming | |||
combobox list item with superscript | Excel Programming | |||
Remove item from combobox. | Excel Programming |