Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default filter a combobox

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
fill combobox depending on selection from another combobox Adam Francis Excel Discussion (Misc queries) 2 July 24th 08 07:39 PM
sort/filter combobox mandy Excel Discussion (Misc queries) 0 December 12th 05 06:08 AM
ComboBox list reliant on the entry from a different ComboBox ndm berry[_2_] Excel Programming 4 October 4th 05 04:40 PM
Tricky ComboBox / Filter query [email protected] Excel Discussion (Misc queries) 0 December 11th 04 10:37 PM
How Do I Load A ComboBox RowSource From The Results Of Another ComboBox Minitman[_4_] Excel Programming 3 October 26th 04 07:58 PM


All times are GMT +1. The time now is 04:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"