I have two (or 3) comboboxes with one controlling the listfillrange of another. It works fine except when I add a line to capture the value of the combobox on a sheet. After the recording the value line, it jumps to the first combobox click event that I don't want:
Private Sub cbo1_click()
Set list2 = New Collection
Me.cbo2.Clear
With sheet1
lr = .Cells(Rows.Count, "a").End(xlUp).Row
On Error Resume Next
For i = 2 To lr
If .Cells(i, "m") = Me.cbo1.Value Then
list2.Add .Cells(i, "n"), CStr(.Cells(i, "n").Value)
End If
Next i
On Error GoTo 0
For Each myValue In list2
Me.cbo2.AddItem myValue
Next
End With
sheet2.Range("A1") = Me.cbo1.value
End Sub
Private Sub cbo2_click()
Set list3 = New Collection
Me.cbo3.Clear
With sheet1
lr = .Cells(Rows.Count, "a").End(xlUp).Row
On Error Resume Next
For i = 2 To lr
If .Cells(i, "n") = Me.cbo2.Value Then
list3.Add .Cells(i, "b"), CStr(.Cells(i, "b").Value)
End If
Next i
On Error GoTo 0
For Each myValue In list3
Me.cbo3.AddItem myValue
Next
End With
sheet2.Range("B1") = Me.cbo2.value
End Sub
When I click combobox2, it triggers the combobox1 event and wipes out the selection in the combobox2 after the line: sheet2.range("b2")=me.cbo2.value. How can I stop this from happening? I tried enableEvents, combobox.list,etc. to no avail. Many Thanks in advance!
Bookmarks