Hi there
How do I preselect items in a listbox based on combobox selection and values stored in matrix.
I have attached the file with a description of what I mean
Thanks
Hi there
How do I preselect items in a listbox based on combobox selection and values stored in matrix.
I have attached the file with a description of what I mean
Thanks
![]()
Private Sub UserForm_Initialize() ComboBox1.List = Application.Transpose(Sheet1.Rows(2).SpecialCells(2).Offset(, 1).SpecialCells(2).Value) ListBox1.List = Sheet1.Columns(1).SpecialCells(2).Offset(1).SpecialCells(2).Value For j = 3 To 13 If Sheet1.Cells(j, "D") = "X" Then ListBox1.Selected(j - 3) = True Next End Sub
If solved remember to mark Thread as solved
Hi Biffer
Try this Combobox1 Change Code![]()
Option Explicit Private Sub ComboBox1_Change() Dim cNo As Long Dim Rng As Range, cel As Range With Sheet1.Rows(2) cNo = .Find(Me.ComboBox1.Value, LookAt:=xlWhole).Column End With Set Rng = Sheet1.Range(("A3"), Sheet1.Range("A3").End(xlDown)) For Each cel In Rng If Intersect(Rows(cel.Row).EntireRow, Columns(cNo).EntireColumn) = "X" Then Me.ListBox1.Selected(cel.Row - 3) = True End If Next cel End Sub
John
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please mark your Thread as SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
Jaslake, thanks...almost!
If I select a name from the combobox, then select another name it aggregates the listbox selections
How do I reset each time I select a name?
Thanks
Geez Biffer...ya didn't say you wanted THAT...try this![]()
Private Sub ComboBox1_Change() Dim cNo As Long, i As Long Dim Rng As Range, cel As Range For i = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(i) = True Then ListBox1.Selected(i) = False End If Next i With Sheet1.Rows(2) cNo = .Find(Me.ComboBox1.Value, LookAt:=xlWhole).Column End With Set Rng = Sheet1.Range(("A3"), Sheet1.Range("A3").End(xlDown)) For Each cel In Rng If Intersect(Rows(cel.Row).EntireRow, Columns(cNo).EntireColumn) = "X" Then Me.ListBox1.Selected(cel.Row - 3) = True End If Next cel End Sub
Thought it was obvious
Awesome - thanks for your help
Actually, it was...just funning with you
Thought it was obvious
You're welcome...glad I could help. Thanks for the Rep.
If this resolves your issue please mark your Thread as SOLVED.
Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks