Hello there.
i have 5 columns in a sheet and 5 listboxes in a userform.
The listboxes ale all set to proporty multiselect.
I would like to loop through the 5 columns and se if the cells contains one of the selected values in the listbox.
The loop should se if:
one of the selected items in listbox1 is in the cell in column1
one of the selected items in listbox2 is in the cell in column2
one of the selected items in listbox3 is in the cell in column3
one of the selected items in listbox4 is in the cell in column4
one of the selected items in listbox5 is in the cell in column5
And if they all are, then i will do some code.
i cant seem to get it to work. have done something similar but with a conbination of comboboxes and textboxes wich have only one value selected.
I ended up with a long code of AND/OR as follows:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ThisWorkbook.Worksheets(3).Activate
For Each cell In ActiveSheet.Range("AD2:AD" & Cells(Rows.Count, 30).End(xlUp).Row)
If cell.Value = "Rekvisition" And Cells(cell.Row, 10) = UserForm1.ComboBox11.Value And Cells(cell.Row, 32) = UserForm1.ComboBox20.Text And (Cells(cell.Row, 3) = UserForm1.ComboBox12.Text Or UserForm1.ComboBox12.Text = "Alle") And (Cells(cell.Row, 9) = UserForm1.ComboBox19.Text Or UserForm1.ComboBox19.Text = "Alle") And (Cells(cell.Row, 5) = UserForm1.ComboBox18.Text Or UserForm1.ComboBox18.Text = "Alle") And Cells(cell.Row, 2).Value >= txtVal1 And Cells(cell.Row, 2).Value <= txtVal2 Then
do some code
End if
Next
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
I have tried to put the selected items in each listbox in a textstring and use it in this code. But it disent work.
Hope you can help
Have a nice day out there
i have 5 columns in a sheet and 5 listboxes in a userform.
The listboxes ale all set to proporty multiselect.
I would like to loop through the 5 columns and se if the cells contains one of the selected values in the listbox.
The loop should se if:
one of the selected items in listbox1 is in the cell in column1
one of the selected items in listbox2 is in the cell in column2
one of the selected items in listbox3 is in the cell in column3
one of the selected items in listbox4 is in the cell in column4
one of the selected items in listbox5 is in the cell in column5
And if they all are, then i will do some code.
i cant seem to get it to work. have done something similar but with a conbination of comboboxes and textboxes wich have only one value selected.
I ended up with a long code of AND/OR as follows:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ThisWorkbook.Worksheets(3).Activate
For Each cell In ActiveSheet.Range("AD2:AD" & Cells(Rows.Count, 30).End(xlUp).Row)
If cell.Value = "Rekvisition" And Cells(cell.Row, 10) = UserForm1.ComboBox11.Value And Cells(cell.Row, 32) = UserForm1.ComboBox20.Text And (Cells(cell.Row, 3) = UserForm1.ComboBox12.Text Or UserForm1.ComboBox12.Text = "Alle") And (Cells(cell.Row, 9) = UserForm1.ComboBox19.Text Or UserForm1.ComboBox19.Text = "Alle") And (Cells(cell.Row, 5) = UserForm1.ComboBox18.Text Or UserForm1.ComboBox18.Text = "Alle") And Cells(cell.Row, 2).Value >= txtVal1 And Cells(cell.Row, 2).Value <= txtVal2 Then
do some code
End if
Next
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
I have tried to put the selected items in each listbox in a textstring and use it in this code. But it disent work.
Hope you can help
Have a nice day out there