Saha H
asked on
Insert checkbox inside the combobox list for multiple selection
How to insert CheckBoxes to the list present in ComboBox?
ASKER
OK thank you...
ASKER
How can i filter data based on multi selection values in Listbox using VBA?
We still do not know what coding language you are using. Also, this is a further question and should be asked on its own. This question needs closing by awarding the poinst after amending the Tags
ASKER
I am using VBA language only.
i got to know that checkbox options are only available with ListBoxes.
I am asking when we select multiple options in that listbox , can we use those values to filter at a time.
i got to know that checkbox options are only available with ListBoxes.
I am asking when we select multiple options in that listbox , can we use those values to filter at a time.
You are really still limited by two filter criteria for AutoFilter even using VBA this applies. You can build an array.
This is sample code to detect what has been selected in the ListBox, but as I said before, this should be a new question.
This is sample code to detect what has been selected in the ListBox, but as I said before, this should be a new question.
Dim Msg As String
Dim iX As Integer
Msg = "You selected" & vbNewLine
For iX = 0 To Me.ListBox1.ListCount - 1
If ListBox1.Selected(iX) Then
Msg = Msg & Me.ListBox1.List(iX) & vbNewLine
End If
Next i
MsgBox Msg
This code assumes you have a ListBox1 and the data is on Sheet1 starting in A1
Sub FilterFromListBox()
Dim iX As Integer
Dim Var As Variant
ReDim Var(0)
Application.ScreenUpdating = False
For iX = 0 To ListBox1.ListCount - 1
If Me.ListBox1.Selected(iX) Then
Var(UBound(Var)) = Me.ListBox1.List(iX)
ReDim Preserve Var(UBound(Var) + 1)
End If
Next iX
Sheet1.Range("A1").CurrentRegion.AutoFilter Field:=3, Criteria1:=Var, Operator:=xlFilterValues
Application.ScreenUpdating = True
End Sub
Thanks Martin. It seems to be Excel VBA required
ASKER
i have one sheet in that, first we have to select year and next we have to select multiple work week values from list box. for those selected values it has to filter the given table.
For year it is working fine but for multiple work week values it is not filtering properly.
Please find the attached dummy sheet.
Book.xlsm
For year it is working fine but for multiple work week values it is not filtering properly.
Please find the attached dummy sheet.
Book.xlsm
Do you intend using the UserForm or the sheet controls. A UserForm is more reliable than ActiveX controls on a sheet.
I've fixed some of your example. there is no button on the sheet, but let me know if this is along the correct lines.
Also, here's my example of filtering from a UserForm
FilterForm.xlsm
Book.xlsm
I've fixed some of your example. there is no button on the sheet, but let me know if this is along the correct lines.
Also, here's my example of filtering from a UserForm
FilterForm.xlsm
Book.xlsm
ASKER
Thank you for examples. I want with ActiveX controls only. But it is not filtering multiple selection of workweeks.
I haven't included code for that in the example yet because it's not clear what you are doing.
ASKER
Please find the attached sheet....
Book.xlsm
Book.xlsm
ASKER
just i want to do multiple selection and that should reflect in that table.
But it is not filtering for single selection also...
But it is not filtering for single selection also...
Your new example totally ignores what I did in the previous example.
ASKER
No no its same only just i have two more buttons for refresh and autofilter.
ASKER
sorry for typo mistake.
Only i have added two buttons . I need only multiple selection should be reflect in available table.
Only i have added two buttons . I need only multiple selection should be reflect in available table.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK thank you..
i have one doubt please can u explain me that. Why You kept this listbox procedure empty? Then how values are displaying in listbox?
Private Sub ListBox1_Click()
End Sub
Private Sub Worksheet_Activate()
''/// populate the ListBox and ComboBox
''///only use cells containing value, dynamic so data can be entered and reflect in list
With Sheet3
Me.ComboBox1.List = .Range(.Cells(2, 1), .Cells(.Rows.Count, 1).End(xlUp)).Value
Me.ListBox1.List = .Range(.Cells(2, 2), .Cells(.Rows.Count, 2).End(xlUp)).Value
End With
End Sub
i have one doubt please can u explain me that. Why You kept this listbox procedure empty? Then how values are displaying in listbox?
Private Sub ListBox1_Click()
End Sub
Private Sub Worksheet_Activate()
''/// populate the ListBox and ComboBox
''///only use cells containing value, dynamic so data can be entered and reflect in list
With Sheet3
Me.ComboBox1.List = .Range(.Cells(2, 1), .Cells(.Rows.Count, 1).End(xlUp)).Value
Me.ListBox1.List = .Range(.Cells(2, 2), .Cells(.Rows.Count, 2).End(xlUp)).Value
End With
End Sub
ASKER
Sir, can you explain me this part of code...
You don't load the ListBox or ComboBox with the Change or Click event, if you do it means that every time you use it it will re-load.
My code loads it when the worksheet is activated, so it is refreshed with any changes to the List.
My code loads it when the worksheet is activated, so it is refreshed with any changes to the List.
The code works as required
In VBA you can use a ListBox with ListStyle = fmListStyleOption.