ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Click event on combobox in a loop (https://www.excelbanter.com/excel-programming/310583-click-event-combobox-loop.html)

smace[_2_]

Click event on combobox in a loop
 

This is my procedu



Private Sub DisplayProductStages()
Dim ListItems As Variant, i As Integer, j As Integer


i = 1

Do Until IsEmpty(Cells(17, i))



If Cells(17, i).Value = Range("F1").Value Then
' found the product - display the product details

j = 18
Do Until IsEmpty(Cells(j, i))
'Find the last row containing product category data
j = j + 1

Loop
ListItems = Worksheets("Sheet1").Range(Cells(18, i), Cells(j
i)).Value
Worksheets("Sheet1").ListBox1.List() = ListItems
End If

i = i + 1
Loop

End Sub


This is the code that calls it:

Private Sub ComboBox2_Change()
Worksheets("Sheet1").ComboBox2.BoundColumn = 1
Range("F1") = ComboBox2.Value
Call DisplayProductStages
End Sub

The code works (albeit slowly) when the call to the procedure was in
ComboBox2_Click() event but doesn't work in the change event. Th
IsEmpty tests work and "stop" in the right place it seems to be th
actual click event that was being called loads of times. .

Thanks for your interest

--
smac

-----------------------------------------------------------------------
smace's Profile: http://www.excelforum.com/member.php...fo&userid=1432
View this thread: http://www.excelforum.com/showthread.php?threadid=26166



All times are GMT +1. The time now is 06:23 AM.

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