Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello Jim,
thank you for the tip but as you see by the correspondence below, I don't think my case can be solved with named lists. Best regards Mats "Jim May" wrote: Mats, Take a look here at a great tutorial of what you want to do: http://www.contextures.com/xlDataVal02.html HTH, Jim "Mats Samson" wrote in message ... Hi Dave, I'm sorry but I was travelling a lot and didn't have any time to go through your proposal until now, but I don't understand how to apply it in my case. I have a sheet named Calculation where I have the two CB's, one for the product names and one for the product categories. In the sheet Products, I have my small product database where column A is my product number (NOT an index number), column B is the product name and column C is the category (Plastics, Fillers, Solvents...). There are more columns but not important for this question. There are about 200 products belonging to one of 6 categories and as you understand when I select the product, I want to limit the list to the selected category, so I don't need to scroll the entire 200 products list. Can you explain how to accomplish this? Thanks Mats "Dave Peterson" wrote: Instead of this portion: If Me.ComboBox1.ListIndex < 0 Then Me.ComboBox2.ListIndex = -1 End If Try using: Me.ComboBox1.clear Dave Peterson wrote: I put two comboboxes from the control toolbox toolbar on a worksheet. I put this code behind the ThisWorkbook module to populate the first combobox whenever the workbook is opened: Option Explicit Private Sub Workbook_Open() With Worksheets("sheet1").ComboBox1 .Clear .AddItem "A" .AddItem "B" .AddItem "C" .AddItem "D" End With End Sub Then I put this code behind the worksheet that contained the two comboboxes: Option Explicit Private Sub ComboBox1_Change() Dim myRng As Range Dim myCell As Range If Me.ComboBox1.ListIndex < 0 Then Me.ComboBox2.ListIndex = -1 End If With Worksheets("sheet1") Set myRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp)) End With For Each myCell In myRng.Cells If LCase(myCell.Value) = LCase(Me.ComboBox1.Value) Then Me.ComboBox2.AddItem myCell.Offset(0, 1).Value End If Next myCell End Sub I matched up on column A and took the value from column B. If you're new to macros, you may want to read David McRitchie's intro at: http://www.mvps.org/dmcritchie/excel/getstarted.htm Mats Samson wrote: Hello, can anyone tell me how to populate a combobox in a sheet with records meeting a criteria set in another combobox, i.e. show only the records (productnames)belonging to the productgroup IĆ¢?Tve selected? I've a small product database in Excel. Thanks Mats -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
fill combobox depending on selection from another combobox | Excel Discussion (Misc queries) | |||
sort/filter combobox | Excel Discussion (Misc queries) | |||
ComboBox list reliant on the entry from a different ComboBox | Excel Programming | |||
Tricky ComboBox / Filter query | Excel Discussion (Misc queries) | |||
How Do I Load A ComboBox RowSource From The Results Of Another ComboBox | Excel Programming |