Combobox filter on data in another row

Flitsing

New Member
Joined
Mar 24, 2009
Messages
4
I have a question about a combobox I use.

It's a personel list and contains multiple field from a worksheet.
It shows Personelnr, Surname, Firstname, Date of birth etc. It also contains the field "Start date" and "End date" This last one is empty when a person is still in service.

I want my combobox to show only the persons that are still in service. I can hide those persons in the sheet, but the Combobox will still show them. How can I fix this?


The rows I used are:
cbxPersoon.RowSource = "Personeel!A5:F500"

The End date is in Column "O"
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Tnx! It helped me a lot already.

Next problem is that I have two Comboboxes so you can search by name or by personel nr. They update eachother and it works fine.

I added the line
Combobox2.AddItem c.Value
so it will be filled with thesame items.
Problem is that it is a multiple row comboxbox and gives a blank row only.

(the first column is the same as Combobox1 (personellnr) with width "0")
Can you help me with this?
 
Upvote 0
Do you mean you have a multicolumn ComboBox?

Code:
With ComboBox2
    .AddItem c.Value
    .List(.ListCount - 1, 1) = c.Offset(0, 1).Value
End With

That puts the value of the cell to the right in column 2 of the ComboBox. Adjust the Offset to suit.
 
Upvote 0
Tnx! I am learning a lot this way :)

I have the following code:
Code:
Dim Sh As Worksheet
    Dim Rng As Range
    Dim c As Range
    Set Sh = Worksheets("Personeel")
    Set Rng = Sh.Range("A5:A" & Sh.Range("A65536").End(xlUp).Row).SpecialCells(xlCellTypeVisible)
    For Each c In Rng
        cbxPersoonsnr.AddItem c.Value
        With cbxPersoon
            .AddItem c.Value
            .List(.ListCount - 1, 1) = c.Offset(0, 1).Value
            .List(.ListCount - 1, 2) = c.Offset(0, 2).Value
            .List(.ListCount - 1, 3) = c.Offset(0, 3).Value
            .List(.ListCount - 1, 4) = c.Offset(0, 4).Value
            .List(.ListCount - 1, 5) = c.Offset(0, 5).Value
        End With
    Next c
It works and the multicolumn combocox cbxPersoon shows multiple columns. My question is probably simple to answer, but how can I configure the column widths?

Before I did it like this.
Code:
cbxPersoon.ColumnWidths = "0;80;35;50;40;20"
 
Upvote 0
Allright, I wasn't paying attention. The code I used already worked for the columnwidths. Sorry for bothering.

But another question popped up: I sorted the sheet by name so a search through Combobox2 is easy (alphabetically). But because of it the IDnumbers are mixed up now. It would be nice to scroll down Combobix1 with following numbers instead of the mixed up ones. I cannot find a thread to fix exactly this. Anyone a solution?
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top